luci: go.chromium.org/luci/common/tsmon/distribution Index | Files

package distribution

import "go.chromium.org/luci/common/tsmon/distribution"

Package distribution contains distribution metrics, fixed width and geometric bucketers.

Index

Package Files

bucketer.go distribution.go

Variables

var DefaultBucketer = GeometricBucketer(math.Pow(10, 0.2), 100)

DefaultBucketer is a bucketer with sensible bucket sizes.

type Bucketer Uses

type Bucketer struct {
    // contains filtered or unexported fields
}

A Bucketer maps samples into discrete buckets.

func FixedWidthBucketer Uses

func FixedWidthBucketer(width float64, numFiniteBuckets int) *Bucketer

FixedWidthBucketer returns a Bucketer that uses numFiniteBuckets+2 buckets:

bucket[0] covers (-Inf...0)
bucket[i] covers [width*(i-1)...width*i) for i > 0 and i <= numFiniteBuckets
bucket[numFiniteBuckets+1] covers [width*numFiniteBuckets...+Inf)

The width must be greater than 0, and the number of finite buckets must be greater than 0.

func GeometricBucketer Uses

func GeometricBucketer(growthFactor float64, numFiniteBuckets int) *Bucketer

GeometricBucketer returns a Bucketer that uses numFiniteBuckets+2 buckets:

bucket[0] covers (−Inf, 1)
bucket[i] covers [growthFactor^(i−1), growthFactor^i) for i > 0 and i <= numFiniteBuckets
bucket[numFiniteBuckets+1] covers [growthFactor^(numFiniteBuckets−1), +Inf)

growthFactor must be positive, and the number of finite buckets must be greater than 0.

func NewBucketer Uses

func NewBucketer(width, growthFactor float64, numFiniteBuckets int) *Bucketer

NewBucketer creates a bucketer from custom parameters.

func (*Bucketer) Bucket Uses

func (b *Bucketer) Bucket(sample float64) int

Bucket returns the index of the bucket for sample. TODO(dsansome): consider reimplementing sort.Search inline to avoid overhead of calling a function to compare two values.

func (*Bucketer) GrowthFactor Uses

func (b *Bucketer) GrowthFactor() float64

GrowthFactor returns the growth factor used to configure this Bucketer.

func (*Bucketer) NumBuckets Uses

func (b *Bucketer) NumBuckets() int

NumBuckets returns the number of buckets including the underflow and overflow buckets.

func (*Bucketer) NumFiniteBuckets Uses

func (b *Bucketer) NumFiniteBuckets() int

NumFiniteBuckets returns the number of finite buckets.

func (*Bucketer) OverflowBucket Uses

func (b *Bucketer) OverflowBucket() int

OverflowBucket returns the index of the overflow bucket.

func (*Bucketer) UnderflowBucket Uses

func (b *Bucketer) UnderflowBucket() int

UnderflowBucket returns the index of the underflow bucket.

func (*Bucketer) Width Uses

func (b *Bucketer) Width() float64

Width returns the bucket width used to configure this Bucketer.

type Distribution Uses

type Distribution struct {
    // contains filtered or unexported fields
}

A Distribution holds a statistical summary of a collection of floating-point values.

func New Uses

func New(b *Bucketer) *Distribution

New creates a new distribution using the given bucketer. Passing a nil Bucketer will use DefaultBucketer.

func (*Distribution) Add Uses

func (d *Distribution) Add(sample float64)

Add adds the sample to the distribution and updates the statistics.

func (*Distribution) Bucketer Uses

func (d *Distribution) Bucketer() *Bucketer

Bucketer returns the bucketer used in this distribution.

func (*Distribution) Buckets Uses

func (d *Distribution) Buckets() []int64

Buckets provides access to the underlying buckets slice. len(Buckets) will be <= Bucketer().NumBuckets()

func (*Distribution) Count Uses

func (d *Distribution) Count() int64

Count returns the number of times Add has been called.

func (*Distribution) LastNonZeroBucket Uses

func (d *Distribution) LastNonZeroBucket() int

LastNonZeroBucket returns the index into Buckets() of the last bucket that is set (non-zero). Returns -1 if Count() == 0.

func (*Distribution) Sum Uses

func (d *Distribution) Sum() float64

Sum returns the sum of all samples passed to Add.

Package distribution imports 3 packages (graph) and is imported by 25 packages. Updated 2018-08-21. Refresh now. Tools for package owners.