tdigest

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package tdigest implements the t-digest algorithm for accurate on-line accumulation of rank-based statistics such as quantiles from "Computing Extremely Accurate Quantiles Using t-Digests" and is based on Ted Dunning's implementation in Java: https://github.com/tdunning/t-digest/blob/master/src/main/java/com/tdunning/math/stats/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Centroid

type Centroid struct {
	Mean   float64
	Weight float64
}

Centroid represents the center of a cluster.

type CentroidsPool

type CentroidsPool interface {
	// Init initializes the pool.
	Init()

	// Get provides a centroid slice from the pool.
	Get(capacity int) []Centroid

	// Put returns a centroid slice to the pool.
	Put(value []Centroid)
}

CentroidsPool provides a pool for variable-sized centroid slices.

func NewCentroidsPool

func NewCentroidsPool(sizes []pool.Bucket, opts pool.ObjectPoolOptions) CentroidsPool

NewCentroidsPool creates a new centroids pool.

type Options

type Options interface {
	// SetCompression sets the compression.
	SetCompression(value float64) Options

	// Compression returns the compression.
	Compression() float64

	// SetPrecision sets the quantile precision.
	SetPrecision(value int) Options

	// Precision returns the quantile precision.
	Precision() int

	// SetCentroidsPool sets the centroids pool.
	SetCentroidsPool(value CentroidsPool) Options

	// CentroidsPool returns the centroids pool.
	CentroidsPool() CentroidsPool

	// Validate validates the options.
	Validate() error
}

Options provides a set of t-digest options.

func NewOptions

func NewOptions() Options

NewOptions creates a new options.

type TDigest

type TDigest interface {

	// Merged returns the merged centroids.
	Merged() []Centroid

	// Unmerged returns the unmerged centroids.
	Unmerged() []Centroid

	// Add adds a value.
	Add(value float64)

	// Min returns the minimum value.
	Min() float64

	// Max returns the maximum value.
	Max() float64

	// Quantile returns the quantile value.
	Quantile(q float64) float64

	// Merge merges another t-digest.
	Merge(tdigest TDigest)

	// Close clsoes the t-digest.
	Close()

	// Reset resets the t-digest.
	Reset()
}

TDigest is the t-digest interface.

func NewTDigest

func NewTDigest(opts Options) TDigest

NewTDigest creates a new t-digest. TODO(xichen): add pooling for t-digests TODO(xichen): add metrics

Jump to

Keyboard shortcuts

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