Documentation ¶
Overview ¶
Package quantile implements "Space-Efficient Online Computation of Quantile Summaries" (Greenwald, Khanna 2001): http://infolab.stanford.edu/~datar/courses/cs361a/papers/quantiles.pdf
This implementation is backed by a skiplist to make inserting elements into the summary faster. Querying is still O(n).
Index ¶
Constants ¶
const EPSILON float64 = 0.01
EPSILON is the precision of the rank returned by our quantile queries
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SliceSummary ¶
SliceSummary is a GK-summary with a slice backend
func NewSliceSummary ¶
func NewSliceSummary() *SliceSummary
NewSliceSummary allocates a new GK summary backed by a DLL
func WeighSummary ¶
func WeighSummary(s *SliceSummary, weight float64) *SliceSummary
WeighSummary applies a weight factor to a slice summary and return it as a new slice.
func (*SliceSummary) BySlices ¶
func (s *SliceSummary) BySlices() []SummarySlice
BySlices returns a slice of Summary slices that represents weighted ranges of values e.g. [0, 1] : 3
[1, 23] : 12 ...
The number of intervals is related to the precision kept in the internal data structure to ensure epsilon*s.N precision on quantiles, but it's bounded. When the bounds of the interval are equal, the weight is the number of times that exact value was inserted in the summary.
func (*SliceSummary) Copy ¶
func (s *SliceSummary) Copy() *SliceSummary
Copy allocates a new summary with the same data
func (*SliceSummary) Insert ¶
func (s *SliceSummary) Insert(v float64, t uint64)
Insert inserts a new value v in the summary paired with t (the ID of the span it was reported from)
func (*SliceSummary) Merge ¶
func (s *SliceSummary) Merge(s2 *SliceSummary)
Merge two summaries entries together
func (*SliceSummary) Quantile ¶
func (s *SliceSummary) Quantile(q float64) float64
Quantile returns an EPSILON estimate of the element at quantile 'q' (0 <= q <= 1)
func (SliceSummary) String ¶
func (s SliceSummary) String() string
type SummarySlice ¶
SummarySlice reprensents how many values are in a [Start, End] range
func BySlicesWeighted ¶
func BySlicesWeighted(summaries ...WeightedSliceSummary) []SummarySlice
BySlicesWeighted BySlices() is the BySlices version but combines multiple weighted slice summaries before returning the histogram
type WeightedSliceSummary ¶
type WeightedSliceSummary struct { Weight float64 *SliceSummary }
WeightedSliceSummary associates a weight to a slice summary.