Class BarSplittingBiasedHistogram
- java.lang.Object
-
- org.terracotta.statistics.derived.histogram.BarSplittingBiasedHistogram
-
- All Implemented Interfaces:
Histogram
public class BarSplittingBiasedHistogram extends Object implements Histogram
An implementation of the histogram algorithm described in: 'Fast Computation of Approximate Biased Histograms on Sliding Windows over Data Streams' [H. Mousavi & C. Zaniolo]This class is *not thread-safe*, safe consumption in a multi-threaded environment will require some form of external locking.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.terracotta.statistics.derived.histogram.Histogram
Histogram.Bucket
-
-
Constructor Summary
Constructors Constructor Description BarSplittingBiasedHistogram(double maxCoefficient, double phi, int expansionFactor, int bucketCount, double barEpsilon, long window)Create a histogram maintained over a sliding time window.BarSplittingBiasedHistogram(double phi, int bucketCount, long window)Create a histogram maintained over a sliding time window.BarSplittingBiasedHistogram(int bucketCount, long window)Create a histogram maintained over a sliding time window.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidevent(double value, long time)Record an event of the givenvalueoccuring at he giventimevoidexpire(long time)Expire old events from all buckets.List<Histogram.Bucket>getBuckets()Returns the histograms bucketsdoublegetMaximum()The maximum value.doublegetMinimum()The minimum value.double[]getQuantileBounds(double quantile)Returns the bounds[minimum, maximum)on the given quantile.protected static doublenextUpIfEqual(double test, double value)longsize()StringtoString()
-
-
-
Constructor Detail
-
BarSplittingBiasedHistogram
public BarSplittingBiasedHistogram(double maxCoefficient, double phi, int expansionFactor, int bucketCount, double barEpsilon, long window)Create a histogram maintained over a sliding time window.The constructed histogram is:
- maintained over
windowsliding window - consists of
bucketCountbuckets - where
b1.size() ~= b0.size * phi - with each bucket internally composed of
expansionFactorbars - with each bar maintaining a count accurate with a fractional error of
barEpsilon - where bars are split when there size exceeds
maxCoefficientof their target size
- Parameters:
maxCoefficient- relative split thresholdphi- histogram bucket bias factorexpansionFactor- number of bars per bucketbucketCount- number of bucketsbarEpsilon- bar count relative errorwindow- sliding window size
- maintained over
-
BarSplittingBiasedHistogram
public BarSplittingBiasedHistogram(int bucketCount, long window)Create a histogram maintained over a sliding time window.The constructed histogram is:
- maintained over
windowsliding window - consists of
bucketCountbuckets - where
b1.size() ~= b0.size * 0.7
- Parameters:
bucketCount- number of bucketswindow- sliding window size
- maintained over
-
BarSplittingBiasedHistogram
public BarSplittingBiasedHistogram(double phi, int bucketCount, long window)Create a histogram maintained over a sliding time window.The constructed histogram is:
- maintained over
windowsliding window - consists of
bucketCountbuckets - where
b1.size() ~= b0.size * phi
- Parameters:
phi- histogram bucket bias factorbucketCount- number of bucketswindow- sliding window size
- maintained over
-
-
Method Detail
-
event
public void event(double value, long time)Record an event of the givenvalueoccuring at he giventime
-
expire
public void expire(long time)
Expire old events from all buckets.
-
getBuckets
public List<Histogram.Bucket> getBuckets()
Description copied from interface:HistogramReturns the histograms buckets- Specified by:
getBucketsin interfaceHistogram- Returns:
- the histogram buckets
-
nextUpIfEqual
protected static double nextUpIfEqual(double test, double value)
-
getMinimum
public double getMinimum()
Description copied from interface:HistogramThe minimum value.This is equal to the inclusive lower bound of the zeroth (0.0) quantile.
- Specified by:
getMinimumin interfaceHistogram- Returns:
- the minimum value
-
getMaximum
public double getMaximum()
Description copied from interface:HistogramThe maximum value.This is equal to highest double value strictly less than the exclusive upper bound of the last (1.0) quantile.
- Specified by:
getMaximumin interfaceHistogram- Returns:
- the maximum value
-
getQuantileBounds
public double[] getQuantileBounds(double quantile)
Description copied from interface:HistogramReturns the bounds[minimum, maximum)on the given quantile.- Specified by:
getQuantileBoundsin interfaceHistogram- Parameters:
quantile- desired quantile- Returns:
- the quantile bounds
-
-