Documentation ¶
Overview ¶
Package quantile provides a library of data structures/algorithms for calculating online quantiles from a stream of data.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HeapMedian ¶
type HeapMedian struct {
// contains filtered or unexported fields
}
HeapMedian keeps track of the median of an entire stream using heaps.
func NewGlobalHeapMedian ¶
func NewGlobalHeapMedian() *HeapMedian
NewGlobalHeapMedian instantiates a global HeapMedian struct. This is equivalent to calling NewHeapMedian(0).
func NewHeapMedian ¶
func NewHeapMedian(window int) (*HeapMedian, error)
NewHeapMedian instantiates a HeapMedian struct.
func (*HeapMedian) Push ¶
func (m *HeapMedian) Push(x float64) error
Push adds a number for calculating the median.
func (*HeapMedian) String ¶
func (m *HeapMedian) String() string
String returns a string representation of the metric.
func (*HeapMedian) Value ¶
func (m *HeapMedian) Value() (float64, error)
Value returns the value of the median.
type IQR ¶
type IQR struct {
// contains filtered or unexported fields
}
IQR keeps track of the interquartile range of a stream using order statistics.
func NewGlobalIQR ¶
NewGlobalIQR instantiates a global IQR struct. This is equivalent to calling NewIQR(0, options...).
type Impl ¶
type Impl int
Impl represents an enum that enumerates the currently supported implementations for the order.Statistic interface.
const ( // AVL represents the AVL tree implementation for the order.Statistic interface AVL Impl = iota // RedBlack represents the red black tree implementation for the order.Statistic interface RedBlack // SkipList represents the skip list implementation for the order.Statistic interface SkipList )
type Interpolation ¶
type Interpolation int
Interpolation represents an enum that enumerates the different interpolation methods that can be chosen when retrieving quantile metrics. In particular, if φ is the quantile value and n is the number of elements, then the raw estimated index for the φ-quantile element is i' = φ * (n - 1). However, this is not guaranteed to be an integer value. Thus, if the quantile of a window of elements actually lies in between two elements, this determines how the returned value will be calculated (depending on those two elements).
const ( // Linear performs linear interpolation between the two elements. // If the φ-quantile i' lies between i and i + 1, then we return // (1 - (i' - i)) * a_i + (i' - i) * a_(i + 1). Linear Interpolation = iota // Lower chooses the lower of the two elements. Lower // Higher chooses the higher of the two elements. Higher // Nearest chooses the element whose index is closest to i'. If // i' is the midpoint between i and i + 1, then ties are broken // based on the parity of i; if i is even, then we choose a_i, and // otherwise choose a_(i + 1). Nearest // Midpoint performs the average of the two elements. Midpoint )
func (Interpolation) Valid ¶
func (i Interpolation) Valid() bool
Valid returns whether or not the Interpolation value is a valid value.
type Median ¶
type Median struct {
// contains filtered or unexported fields
}
Median keeps track of the median of a stream using order statistics.
func NewGlobalMedian ¶
NewGlobalMedian instantiates a global Median struct. This is equivalent to calling NewMedian(0, options...).
func NewMedian ¶
NewMedian instantiates a Median struct. The implementation of the underlying data structure for tracking order statistics can be configured by passing in a constant of type Impl.
type Option ¶
Option is an optional argument for creating quantile-based metrics, which sets an optional field for creating a Quantile.
func ImplOption ¶
ImplOption creates an option that sets the implementation for the underlying data structure.
func InterpolationOption ¶
func InterpolationOption(i Interpolation) Option
InterpolationOption creates an option that sets the interpolation method.
type Quantile ¶
type Quantile struct {
// contains filtered or unexported fields
}
Quantile keeps track of the quantile of a stream using order statistics.
func NewGlobalQuantile ¶
NewGlobalQuantile instantiates a global Quantile struct. This is equivalent to calling New(0, options...).
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package heap provides the implementation for heaps.
|
Package heap provides the implementation for heaps. |
Package order contains the interfaces for various implementations of order statistics-based data structures.
|
Package order contains the interfaces for various implementations of order statistics-based data structures. |
Package ost provides the interfaces for order statistic trees, which are binary trees with the ability to perform log(n) time searches for elements in the tree with a specified rank, as well as log(n) time retrieval for the rank of a specified element in the tree.
|
Package ost provides the interfaces for order statistic trees, which are binary trees with the ability to perform log(n) time searches for elements in the tree with a specified rank, as well as log(n) time retrieval for the rank of a specified element in the tree. |
avl
Package avl provides the implementation for an AVL tree, which satisfies the ost package interfaces, as well as the order package interfaces.
|
Package avl provides the implementation for an AVL tree, which satisfies the ost package interfaces, as well as the order package interfaces. |
rb
Package rb provides the implementation for a red black tree, which satisfies the ost package interfaces, as well as the order package interfaces.
|
Package rb provides the implementation for a red black tree, which satisfies the ost package interfaces, as well as the order package interfaces. |
Package skiplist provides the implementation for skiplists.
|
Package skiplist provides the implementation for skiplists. |