Documentation ¶
Overview ¶
Package loghist provides integer histograms with exponentially growing bucket sizes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
Bucket describes a bucket in the histogram for values [left, right] containing Count many values.
type Hist ¶
type Hist struct { Overflow int // Number of added values > Max Underflow int // Number of added values < 0 // contains filtered or unexported fields }
Hist is a histogram of non-negative integer values whose bin size increases exponentially and covers the intervall [0,Max]. The bins are grouped into blocks of 1<<bist equal-sized bins. The first block has a bin size of 1; in each consecutive block the bin size is doubled. The resolution of the histogram is 1/(1<<bits).
func New ¶
New returns a new Hist capable of storing values from 0 to (at least) max with a resolution of bits. N will be 1<<bits.
func (*Hist) Add ¶
Add counts the value v. Values below 0 or larger than h.Max are not stored in the histogram but counted in Underflow and Overflow.
func (*Hist) Average ¶
Average returns an approximation to the average of all non-over/underflowing values added to h.
func (*Hist) MustAdd ¶
MustAdd works like Add but will panic if v under- or overflows the allowed range of [0,h.Max].
func (Hist) Parameters ¶
Parameters returns the number of bits resolution of the histogram and the maximum value which can be stored without overflowing.
func (*Hist) Quantiles ¶
Quantiles returns an approximation to the sample quantiles for the given probabilities p which must be a sorted list of increasing float64s from the intervall [0,1]. Quantiles ignores overflowing and underflowing values in h and can compute only an approximation if the bin sizes become large: The approximation will overestimate the real sample quantile.