Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Percentile ¶
Percentile calculates the percentile `p` based on the buckets. The buckets will be sorted by this function (i.e. no sorting needed before calling this function). The percentile value is interpolated assuming a linear distribution within a bucket. However, if the percentile falls into the highest bucket, the upper bound of the 2nd highest bucket is returned. A natural lower bound of 0 is assumed if the upper bound of the lowest bucket is greater 0. In that case, interpolation in the lowest bucket happens linearly between 0 and the upper bound of the lowest bucket. However, if the lowest bucket has an upper bound less or equal to 0, this upper bound is returned if the percentile falls into the lowest bucket.
An error is returned if:
- `buckets` has fewer than 2 elements
- the highest bucket is not +Inf
- p<0
- p>100