median ( seq -- x ) (original) (raw)
Vocabulary
math.statistics
Inputs
Outputs
x | a non-negative real number |
---|
Word description
Computes the median of seq by finding the middle element of the sequence using kth-smallest. If there is an even number of elements in the sequence, the median is not unique, so the mean of the two middle values is output.
Examples
USING: math.statistics prettyprint ; { 1 2 3 } median .
2
USING: math.statistics prettyprint ; { 1 2 3 4 } median .
2+1/2
Errors
Throws a signal-error. (divide by zero) if the sequence is empty.
Definition