Stats
numbers_sum¶
Sum a list of numbers from positional arguments or stdin. Handles integers and floats. Non-numeric lines are silently skipped. See also: sum() in numbers/sum.sh (integers only, legacy name).
Example¶
numbers_sum 1 2 3 # => 6
seq 1 100 | numbers_sum # => 5050
Arguments¶
- ... (number): Numbers to sum, or pipe one value per line via stdin
Exit codes¶
- 0: Always
Output on stdout¶
- Sum of values (%g format — no trailing zeros)
numbers_min¶
Return the smallest value from a list of numbers. Handles integers and floats. Accepts any number of values. See also: num_min() in numbers/math.sh (pairwise, exactly two arguments).
Example¶
numbers_min 3 1 4 1 5 9 # => 1
seq 1 10 | numbers_min # => 1
Arguments¶
- ... (number): Numbers to compare, or pipe one value per line via stdin
Exit codes¶
- 0: Always
- 1: No input
Output on stdout¶
- Minimum value
numbers_max¶
Return the largest value from a list of numbers. Handles integers and floats. Accepts any number of values. See also: num_max() in numbers/math.sh (pairwise, exactly two arguments).
Example¶
numbers_max 3 1 4 1 5 9 # => 9
seq 1 10 | numbers_max # => 10
Arguments¶
- ... (number): Numbers to compare, or pipe one value per line via stdin
Exit codes¶
- 0: Always
- 1: No input
Output on stdout¶
- Maximum value
numbers_mean¶
Compute the arithmetic mean of a list of numbers. Handles integers and floats. See also: average() in numbers/sum.sh (legacy name).
Example¶
numbers_mean 1 2 3 # => 2
numbers_mean 1 2 # => 1.5
seq 1 10 | numbers_mean # => 5.5
Arguments¶
- ... (number): Numbers to average, or pipe one value per line via stdin
Exit codes¶
- 0: Always
- 1: No input
Output on stdout¶
- Arithmetic mean (%g format — no trailing zeros)
numbers_median¶
Compute the median of a list of numbers. For an odd count, returns the middle value. For an even count, returns the mean of the two middle values.
Example¶
numbers_median 3 1 4 1 5 # => 3
numbers_median 1 2 3 4 # => 2.5
Arguments¶
- ... (number): Numbers, or pipe one value per line via stdin
Exit codes¶
- 0: Always
- 1: No input
Output on stdout¶
- Median value (%g format)
numbers_mode¶
Return the most frequently occurring value in a list. On a tie, returns the smallest value among those with the highest frequency. Handles integers and floats.
Example¶
numbers_mode 1 2 2 3 3 3 # => 3
numbers_mode 1 1 2 2 # => 1 (tie: smallest wins)
Arguments¶
- ... (number): Numbers, or pipe one value per line via stdin
Exit codes¶
- 0: Always
- 1: No input
Output on stdout¶
- Most frequent value
numbers_stdev¶
Compute the population standard deviation of a list of numbers. Uses the one-pass variance formula: var = E[x²] - (E[x])². For sample standard deviation (divides by N-1) use numbers_stdev_sample.
Example¶
numbers_stdev 2 4 4 4 5 5 7 9 # => 2
numbers_stdev 1 2 3 # => 0.816497
Arguments¶
- ... (number): Numbers, or pipe one value per line via stdin
Exit codes¶
- 0: Always
- 1: Fewer than one value provided
Output on stdout¶
- Population standard deviation (%g format)
numbers_stdev_sample¶
Compute the sample standard deviation (Bessel's correction, divides by N-1).
Example¶
numbers_stdev_sample 2 4 4 4 5 5 7 9 # => 2.13809
Arguments¶
- ... (number): Numbers, or pipe one value per line via stdin
Exit codes¶
- 0: Always
- 1: Fewer than two values provided
Output on stdout¶
- Sample standard deviation (%g format)