percentile
Calculates the p-th percentile of an array of numbers using linear interpolation between
the closest ranks. Returns NaN for an empty array. Does not mutate the input array.
Available since v3.0.3
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
array | readonly number[] | The array of numbers |
p | number | The percentile to compute, from `0` to `100` |
Returns
Section titled “Returns”number — The interpolated value at percentile p, or NaN if the array is empty
Examples
Section titled “Examples”Median via the 50th percentile
Section titled “Median via the 50th percentile”The 50th percentile is equivalent to the median.
Min and max via 0 and 100
Section titled “Min and max via 0 and 100”The 0th and 100th percentiles are the min and max.
