Skip to content

quantileSorted

quantileSorted(x, p): number

Defined in: src/quantile_sorted.js:17

This is the internal implementation of quantiles: when you know that the order is sorted, you don’t need to re-sort it, and the computations are faster.

This implements the linear interpolation method (type=7 in R/numpy), which is the default in numpy.percentile and R’s quantile.

number[]

sample of one or more data points

number

desired quantile: a number between 0 to 1, inclusive

number

quantile value

if p ix outside of the range from 0 to 1

if x is empty

quantileSorted([3, 6, 7, 8, 8, 9, 10, 13, 15, 16, 20], 0.5); // => 9