Documentation ¶
Overview ¶
Package histogram provides a simple histogram library, with support for interpolation and percentile calculation.
The Histogram stores a count of the number of occurrences for each value. This count can later be used to interpolate expected counts for unknown values, and to calculate the percentile position of a value (number of equal or smaller values). The percentile calculation also does implicit interpolation if needed.
Sample usage
h := NewHistogram() for _ , v := range values { h.Add(v) } p := GetPercentile(x)
Index ¶
- Variables
- type Histogram
- func (h *Histogram) Add(v int)
- func (h *Histogram) AddCount(v, count int)
- func (h *Histogram) Get(v int) (float64, error)
- func (h *Histogram) GetAtPercentile(p float64) int
- func (h *Histogram) GetInterpolated(v int) (float64, error)
- func (h *Histogram) GetPercentile(v int) float64
- func (h *Histogram) Len() int
- func (h *Histogram) Update(h2 *Histogram)
Constants ¶
This section is empty.
Variables ¶
var ErrExtrapolation = errors.New("Extrapolation of histogram values not supported")
This library does not support extrapolation of histogram values outside the range of known values. An ErrExtrapolation is used if such extrapolation is attempted.
Functions ¶
This section is empty.
Types ¶
type Histogram ¶
type Histogram struct {
// contains filtered or unexported fields
}
Histogram holds the values and can perform interpolation and percentile calculation.
func (*Histogram) GetAtPercentile ¶
GetAtPercentile gets the value at percentile p
func (*Histogram) GetInterpolated ¶
GetInterpolated returns the frequency for value v. Automatically performs interpolation if needed.
func (*Histogram) GetPercentile ¶
GetPercentile returns the percentile position for value v. Automatically performs interpolation if needed.