Documentation
¶
Index ¶
- Variables
- func ComputeRSE(k int, rank float64, isHighRankAccuracyMode bool, n int64) float64
- type ConfidenceOptionFunc
- type Item
- type SearchCriteriaOptionFunc
- type Sketch
- func (s *Sketch) All() []Item
- func (s *Sketch) CDF(splitPoints []float32, isInclusive bool) ([]float64, error)
- func (s *Sketch) CompactorDetailString(showAllData bool) string
- func (s *Sketch) IsEmpty() bool
- func (s *Sketch) IsEstimationMode() bool
- func (s *Sketch) IsHighRankAccuracyMode() bool
- func (s *Sketch) K() int
- func (s *Sketch) MaxItem() (float32, error)
- func (s *Sketch) Merge(other *Sketch) error
- func (s *Sketch) MinItem() (float32, error)
- func (s *Sketch) N() int64
- func (s *Sketch) NumRetained() int
- func (s *Sketch) PMF(splitPoints []float32, opts ...SearchCriteriaOptionFunc) ([]float64, error)
- func (s *Sketch) Quantile(normRank float64, opts ...SearchCriteriaOptionFunc) (float32, error)
- func (s *Sketch) QuantileLowerBound(rank float64, opts ...ConfidenceOptionFunc) (float32, error)
- func (s *Sketch) QuantileUpperBound(rank float64, opts ...ConfidenceOptionFunc) (float32, error)
- func (s *Sketch) Quantiles(ranks []float64, opts ...SearchCriteriaOptionFunc) ([]float32, error)
- func (s *Sketch) Rank(quantile float32, opts ...SearchCriteriaOptionFunc) (float64, error)
- func (s *Sketch) RankLowerBound(rank float64, opts ...ConfidenceOptionFunc) (float64, error)
- func (s *Sketch) RankUpperBound(rank float64, opts ...ConfidenceOptionFunc) (float64, error)
- func (s *Sketch) Ranks(quantiles []float32, opts ...SearchCriteriaOptionFunc) ([]float64, error)
- func (s *Sketch) Reset()
- func (s *Sketch) SortedView() (*quantilecommon.NumericSortedView[float32], error)
- func (s *Sketch) String() string
- func (s *Sketch) Update(item float32) error
- type SketchOptionFunc
Constants ¶
This section is empty.
Variables ¶
var (
ErrEmpty = errors.New("operation is undefined for an empty sketch")
)
Functions ¶
func ComputeRSE ¶
ComputeRSE returns an a priori estimate of relative standard error (ComputeRSE, expressed as a number in [0,1]). Derived from Lemma 12 in https://arxiv.org/abs/2004.01668v2, but the constant factors were adjusted based on empirical measurements. K is the sketch's k. Rank is the normalized rank, in [0,1]. isHighRankAccuracyMode is true if the sketch is configured for high rank accuracy. N is the total number of items in the stream.
Types ¶
type ConfidenceOptionFunc ¶
type ConfidenceOptionFunc func(*confidenceOptions)
ConfidenceOptionFunc is a function type that configures confidence interval options.
func WithNumStdDev ¶
func WithNumStdDev(n int) ConfidenceOptionFunc
WithNumStdDev sets the number of standard deviations to use for confidence intervals.
type SearchCriteriaOptionFunc ¶
type SearchCriteriaOptionFunc func(*searchCriteria)
SearchCriteriaOptionFunc defines a function type used to configure or modify a searchCriteria instance.
func WithExclusiveSearch ¶
func WithExclusiveSearch() SearchCriteriaOptionFunc
WithExclusiveSearch creates a SearchCriteriaOptionFunc that sets the search criteria to be exclusive.
type Sketch ¶
type Sketch struct {
// contains filtered or unexported fields
}
func NewSketch ¶
func NewSketch(options ...SketchOptionFunc) (*Sketch, error)
func (*Sketch) CompactorDetailString ¶
CompactorDetailString returns a string representation of the compactors in the sketch. Each compactor string is prepended by the compactor lgWeight, the current number of retained quantiles of the compactor and the current nominal capacity of the compactor.
func (*Sketch) IsEmpty ¶
IsEmpty checks if the sketch contains no data and returns true if it is empty, otherwise false.
func (*Sketch) IsEstimationMode ¶
IsEstimationMode returns true if the sketch is in estimation mode.
func (*Sketch) IsHighRankAccuracyMode ¶
IsHighRankAccuracyMode returns whether the sketch is in high rank accuracy mode. If true, the high ranks are prioritized for better accuracy. If not, low ranks are prioritized for better accuracy.
func (*Sketch) K ¶
K returns the k parameter which controls the accuracy of the sketch and its memory space usage.
func (*Sketch) MaxItem ¶
MaxItem retrieves the maximum item in the sketch. Returns an error if the sketch is empty.
func (*Sketch) MinItem ¶
MinItem retrieves the minimum item in the sketch. Returns an error if the sketch is empty.
func (*Sketch) NumRetained ¶
NumRetained returns the number of quantiles retained by the sketch.
func (*Sketch) PMF ¶
func (s *Sketch) PMF(splitPoints []float32, opts ...SearchCriteriaOptionFunc) ([]float64, error)
PMF is the equivalent of the NumericSortedView PMF function. the default option is inclusive.
func (*Sketch) Quantile ¶
func (s *Sketch) Quantile(normRank float64, opts ...SearchCriteriaOptionFunc) (float32, error)
Quantile gets the approximate quantile of the given normalized rank. normRank is the normalized rank in the range [0.0, 1.0]. If isInclusive is true, rank includes all the quantiles less than or equal to the quantile directly corresponding to the given rank. If not, rank includes all the quantiles less than the quantile directly corresponding to the given rank. The default option is inclusive.
func (*Sketch) QuantileLowerBound ¶
func (s *Sketch) QuantileLowerBound( rank float64, opts ...ConfidenceOptionFunc, ) (float32, error)
QuantileLowerBound returns the lower bound of the quantile confidence interval in which the quantile of the given rank exists. numStdDev is the number of standard deviations. Must be 1, 2, or 3. default numStdDev is 2. When numStdDev is 2, the approximate probability that the true quantile is within the confidence interval specified by the upper and lower quantile bounds for this sketch is 0.95.
func (*Sketch) QuantileUpperBound ¶
func (s *Sketch) QuantileUpperBound( rank float64, opts ...ConfidenceOptionFunc, ) (float32, error)
QuantileUpperBound returns the upper bound of the quantile confidence interval in which the quantile of the given rank exists. numStdDev is the number of standard deviations. Must be 1, 2, or 3. default numStdDev is 2. When numStdDev is 2, the approximate probability that the true quantile is within the confidence interval specified by the upper and lower quantile bounds for this sketch is 0.95.
func (*Sketch) Quantiles ¶
func (s *Sketch) Quantiles(ranks []float64, opts ...SearchCriteriaOptionFunc) ([]float32, error)
Quantiles gets quantiles from the given array of normalized ranks. ranks is the normalized ranks, each of which must be in the valid interval [0.0, 1.0]. The default option is inclusive search.
func (*Sketch) Rank ¶
func (s *Sketch) Rank(quantile float32, opts ...SearchCriteriaOptionFunc) (float64, error)
Rank returns normalized rank corresponding to the given quantile and search criterion. The default option is inclusive search.
func (*Sketch) RankLowerBound ¶
func (s *Sketch) RankLowerBound( rank float64, opts ...ConfidenceOptionFunc, ) (float64, error)
RankLowerBound returns the approximate lower bound of a rank confidence interval which the true rank of the given rank exists. rank should be in the 0 to 1.0. numStdDev is the number of standard deviations. Must be 1, 2, or 3. default numStdDev is 2. When numStdDev is 2, the approximate probability that the true quantile is within the confidence interval specified by the upper and lower quantile bounds for this sketch is 0.95.
func (*Sketch) RankUpperBound ¶
func (s *Sketch) RankUpperBound( rank float64, opts ...ConfidenceOptionFunc, ) (float64, error)
RankUpperBound returns the approximate upper bound of the rank confidence interval in which the true rank of the given rank exists. rank should be in the 0 to 1.0. numStdDev is the number of standard deviations. Must be 1, 2, or 3. default numStdDev is 2. When numStdDev is 2, the approximate probability that the true quantile is within the confidence interval specified by the upper and lower quantile bounds for this sketch is 0.95.
func (*Sketch) Ranks ¶
func (s *Sketch) Ranks(quantiles []float32, opts ...SearchCriteriaOptionFunc) ([]float64, error)
Ranks returns normalized ranks corresponding to the given quantiles and search criterion. The default option is inclusive.
func (*Sketch) SortedView ¶
func (s *Sketch) SortedView() (*quantilecommon.NumericSortedView[float32], error)
SortedView returns a sorted view of the data retained by the sketch, or an error if refreshing the view fails.
type SketchOptionFunc ¶
type SketchOptionFunc func(*Sketch)
func WithHighRankAccuracyMode ¶
func WithHighRankAccuracyMode(isHRAMode bool) SketchOptionFunc
WithHighRankAccuracyMode sets the high rank accuracy mode for the Sketch.