quantile
Calculates the value at a q quantile using sorted values and linear interpolation.
API Reference
Signature
Parameters
Returns
Returns sorted[lower] + (sorted[upper] - sorted[lower]) * fraction, where position = (n - 1) * q.
Throws
- Throws if
valuesis not a non-empty array. - Throws if any value is non-finite.
- Throws if
qis non-finite or outside[0, 1].
Agent Contract
Agent Notes
- Use
quantile(values, q)rather thanpercentile;percentileis not a public API. - Pass
qas a value from0through1, not as0through100. - The input array is sorted on a copy.