Numbers.median()
Syntax
function median(...values: number[]): number
Gets the median of a sequence of numbers.
Parameters | |
values
Rest
|
The values from which to determine the median. The values do not have to be sorted. If there are an odd number of values, this function extracts the middle value. If there are an even number of values, this function extracts the average of the middle two values. |
Example
import { Numbers } from 'potence';
Numbers.median(9, 2, 3); // -> 3
Numbers.median(9, 4, 1, 10); // -> 6.5
Remarks
If the sequence is not sorted, this function will sort it first.