Compute value below a percentage of observations in the data. Uses the nearest rank method, i.e. ceil(percentile * N), where N = number of elements in data.
NaNs (Not a Numbers) are excluded from the computation. The following example will return {1,2}
auto percentiles = utilstats::percentiles({1, 0, 3, 2}, {0.25, 0.75});
std::vector< T > percentiles(std::vector< T > data, const std::vector< double > &percentiles)
Compute value below a percentage of observations in the data. Uses the nearest rank method,...
Definition statsutils.h:84
See also https://en.wikipedia.org/wiki/Percentile
- Parameters
-
data | to compute percentiles on |
percentiles | in the range [0 1] |
- Returns
- values below the percentage given by the percentiles.
- Exceptions
-
Exception | if any percentile is less than 0 or larger than 1 |