com.splout.db.benchmark
Class PositiveHistogram

java.lang.Object
  extended by com.splout.db.benchmark.PositiveHistogram
Direct Known Subclasses:
HistogramWithStats

public class PositiveHistogram
extends java.lang.Object

A class for computing approximated histograms, keeping a constant resolution, constant amount of memory, and without the needed of pre or post processing. WARNING: It only works for positive values. And if they are distributed far from 0, then will not work properly as well.


Field Summary
protected  int[] buckets
           
protected  long count
           
protected  double upperLimit
           
 
Constructor Summary
PositiveHistogram(int bits, double initialUpperLimit)
          2^bits will be number of buckets.
 
Method Summary
 void add(double value)
          Add a new value to the histogram
 int bucketFor(java.lang.Double value)
          Return the bucket index for a given value.
 int[] getBuckets()
          Return the list of buckets.
 double getBucketSize()
           
 long getCount()
          Returns the number of elements that was added to the histogram.
 double getLeftAccumulatedProbability(double value)
          Computes the accumulated probability for the values at the left of the provided value
 double[] getNormalizedHistogram()
           
 double getRigthAccumulatedProbability(double value)
          Computes the accumulated probability for the values at the right of the provided value
 double getUpperLimit()
          Returns the maximum value that can be keep if the current histogram without needing to redistribute the buckets.
protected  void resize(double value)
           
 java.lang.String toTSV()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buckets

protected int[] buckets

upperLimit

protected double upperLimit

count

protected long count
Constructor Detail

PositiveHistogram

public PositiveHistogram(int bits,
                         double initialUpperLimit)
2^bits will be number of buckets. If known, it is useful to provide an initialUpperLimit. If it is not known, just set it as 0

Method Detail

add

public void add(double value)
Add a new value to the histogram


resize

protected void resize(double value)

bucketFor

public int bucketFor(java.lang.Double value)
Return the bucket index for a given value.


getUpperLimit

public double getUpperLimit()
Returns the maximum value that can be keep if the current histogram without needing to redistribute the buckets.


getBuckets

public int[] getBuckets()
Return the list of buckets. They represent the values between 0 and getUpperLimit()


getCount

public long getCount()
Returns the number of elements that was added to the histogram.


getRigthAccumulatedProbability

public double getRigthAccumulatedProbability(double value)
Computes the accumulated probability for the values at the right of the provided value


getLeftAccumulatedProbability

public double getLeftAccumulatedProbability(double value)
Computes the accumulated probability for the values at the left of the provided value


getNormalizedHistogram

public double[] getNormalizedHistogram()

getBucketSize

public double getBucketSize()

toTSV

public java.lang.String toTSV()


Copyright © 2012-2013 Datasalt Systems S.L.. All Rights Reserved.