stat

package
v0.0.0-...-fd2add7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2016 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package stat implements facilities for storing distribution sketches and updating them

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bin

type Bin struct {
	X      float64 // Starting value. Bin is [X, X+width)
	Weight float64
}

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

func NewHistogram(min, max float64, n int) *Histogram

NewHistogram creates and returns a new histogram object.

func (*Histogram) Histogram

func (h *Histogram) Histogram() []*Bin

Histogram returns the current histogram.

func (*Histogram) Put

func (h *Histogram) Put(x float64, weight float64)

Put places the sample with value x and given weight (must be positive) into the histogram.

func (*Histogram) Width

func (h *Histogram) Width() float64

Width returns the histogram bin width in the value domain

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) Add

func (x *Moment) Add(sample float64)

Add adds sample with weight one.

func (*Moment) AddWeighted

func (x *Moment) AddWeighted(sample float64, weight float64)

AddWeighted adds sample with the given weight.

func (*Moment) Average

func (x *Moment) Average() float64

Average returns the weighted average of samples added to the sketch.

func (*Moment) Count

func (x *Moment) Count() int64

Count returns the number of samples added to this sketch.

func (*Moment) Init

func (x *Moment) Init()

Init initializes the sketch.

func (*Moment) IsEmpty

func (x *Moment) IsEmpty() bool

IsEmpty returns true if no samples have been added to this sketch yet.

func (*Moment) Mass

func (x *Moment) Mass() float64

Mass returns the sum of absolute values of the sample-weight product of all added samples.

func (*Moment) Max

func (x *Moment) Max() float64

Ma returns the largest sample added to this sketch.

func (*Moment) Min

func (x *Moment) Min() float64

Min returns the smallest sample added to this sketch.

func (*Moment) Moment

func (x *Moment) Moment(k float64) float64

Moment returns the weighted k-th moment of the samples added to this sketch.

func (*Moment) StdDev

func (x *Moment) StdDev() float64

StdDev returns the weighted standard deviation of the samples added to this sketch.

func (*Moment) Variance

func (x *Moment) Variance() float64

Variance returns the weighted variance of the samples added to this sketch.

func (*Moment) Weight

func (x *Moment) Weight() float64

Weight returns the total sample weight 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) Init

func (x *TimeSampler) Init()

Init initializes the time sampler.

func (*TimeSampler) Moment

func (x *TimeSampler) Moment() *Moment

Moment returns the underlying moment sketch.

func (*TimeSampler) Start

func (x *TimeSampler) Start()

Start initiates a new measurement.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL