percentile es-toolkit
Calculates the value at the given percentile of an array of numbers.
percentile sorts the array in ascending order and returns the element at the nearest rank (Nearest rank method).
Usage
percentile(arr, percentile)
Use percentile when you want to find the value at a specific percentile of a numeric array. For example, the 50th percentile is the median, and the 75th percentile is the value below which 75% of the data falls.
Parameters
An array of numbers to calculate the percentile from.
The percentile to compute, in the range [0, 100].
Returns
Returns the value at the given percentile. Returns NaN if the array is empty.
Throws
Throws an error if percentile is NaN, less than 0, or greater than 100.
Source: es-toolkit
Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.