percentile

percentile(x, probs, sorted=False)

Percentiles of a sample.

Mirrors the C# Statistics.Percentile: zero-based linear interpolation (R quantile() Type 7).

Parameters

Name Type Description Default
x array_like required
probs array_like Probabilities in [0, 1]. required
sorted bool Set True when x is already sorted ascending, to skip re-sorting it. False

Returns

Name Type Description
numpy.ndarray One percentile per entry of probs.

Examples

>>> from corehydropy import percentile
>>> percentile([1, 2, 3, 4, 5], probs=[0.25, 0.5, 0.75])
array([2., 3., 4.])