Documentation ¶
Overview ¶
Package stat implements facilities for storing distribution sketches and updating them
Index ¶
- type Bin
- type Histogram
- type Moment
- func (x *Moment) Add(sample float64)
- func (x *Moment) AddWeighted(sample float64, weight float64)
- func (x *Moment) Average() float64
- func (x *Moment) Count() int64
- func (x *Moment) Init()
- func (x *Moment) IsEmpty() bool
- func (x *Moment) Mass() float64
- func (x *Moment) Max() float64
- func (x *Moment) Min() float64
- func (x *Moment) Moment(k float64) float64
- func (x *Moment) StdDev() float64
- func (x *Moment) Variance() float64
- func (x *Moment) Weight() float64
- type SlidingMoment
- func (x *SlidingMoment) Init(resolution int, duration time.Duration)
- func (x *SlidingMoment) Mass() float64
- func (x *SlidingMoment) Slot(t time.Time) *Moment
- func (x *SlidingMoment) Slots() ([]*Moment, time.Time)
- func (x *SlidingMoment) TailWeight(tail int) float64
- func (x *SlidingMoment) TimeSpan() time.Duration
- func (x *SlidingMoment) Weight() float64
- type TimeSampler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Histogram ¶
type Histogram struct {
// contains filtered or unexported fields
}
Histogram is a simple static histogram structure. It consumes a stream of floating point numbers and can output a histogram at any time.
func NewHistogram ¶
NewHistogram creates and returns a new histogram object.
type Moment ¶
type Moment struct {
// contains filtered or unexported fields
}
Moment is a streaming sketch data structure. It keeps track of moment statistics for an incoming stream of floating point numbers.
func (*Moment) AddWeighted ¶
AddWeighted adds sample with the given weight.
func (*Moment) Mass ¶
Mass returns the sum of absolute values of the sample-weight product of all added samples.
func (*Moment) Moment ¶
Moment returns the weighted k-th moment of the samples added to this sketch.
func (*Moment) StdDev ¶
StdDev returns the weighted standard deviation of the samples added to this sketch.
type SlidingMoment ¶
type SlidingMoment struct {
// contains filtered or unexported fields
}
Sliding moment is a composite sketch. It keeps track of a sliding window of time, divided into slots where each slot is a moment sketch.
func NewSlidingMoment ¶
func NewSlidingMoment(resolution int, duration time.Duration) *SlidingMoment
NewSlidingMoment creates a new sketch with resolution-many slots, and each slot being responsible for a time interval of duration/resolution.
func (*SlidingMoment) Init ¶
func (x *SlidingMoment) Init(resolution int, duration time.Duration)
Init initializes the sketch.
func (*SlidingMoment) Mass ¶
func (x *SlidingMoment) Mass() float64
Mass returns the total mass across all time slot sketches.
func (*SlidingMoment) Slot ¶
func (x *SlidingMoment) Slot(t time.Time) *Moment
Moment returns a pointer to the current moment structure corresponding to time t.
func (*SlidingMoment) Slots ¶
func (x *SlidingMoment) Slots() ([]*Moment, time.Time)
Slots returns a slice of moment sketches, ordered from most recent to least recent.
func (*SlidingMoment) TailWeight ¶
func (x *SlidingMoment) TailWeight(tail int) float64
TailWeight returns the total sample weight in the tail least-recent time slots.
func (*SlidingMoment) TimeSpan ¶
func (x *SlidingMoment) TimeSpan() time.Duration
TimeSpan returns the length of time that is captured by this sketch.
func (*SlidingMoment) Weight ¶
func (x *SlidingMoment) Weight() float64
Weight returns the total weight of all samples across all time slots.
type TimeSampler ¶
type TimeSampler struct {
// contains filtered or unexported fields
}
TimeSampler is a facility for collection stopwatch statistics over multiple experiments. TimeSampler is not synchronized. Only one measurement can take place at a time.
func (*TimeSampler) Average ¶
func (x *TimeSampler) Average() float64
Average returns the average experiment time.
func (*TimeSampler) Moment ¶
func (x *TimeSampler) Moment() *Moment
Moment returns the underlying moment sketch.
func (*TimeSampler) StdDev ¶
func (x *TimeSampler) StdDev() float64
StdDev returns the standard deviation across all experiments.
func (*TimeSampler) Stop ¶
func (x *TimeSampler) Stop()
Stop ends an experiment and records the elapsed time as a sample in an underlying moment sketch.