quantileRankSorted
quantileRankSorted(
x,value):number
Defined in: src/quantile_rank_sorted.js:18
This function returns the quantile in which one would find the given value in the given array. With a sorted array, leveraging binary search, we can find this information in logarithmic time.
Parameters
Section titled “Parameters”number[]
input
number
the value for which to find the quantile rank
Returns
Section titled “Returns”number
the quantile rank
Throws
Section titled “Throws”if x is empty
Example
Section titled “Example”quantileRankSorted([1, 2, 3, 4], 3); // => 0.75quantileRankSorted([1, 2, 3, 3, 4], 3); // => 0.7quantileRankSorted([1, 2, 3, 4], 6); // => 1quantileRankSorted([1, 2, 3, 3, 5], 4); // => 0.8