public class Histogram<K extends java.lang.Comparable> extends java.util.TreeMap<K,Histogram.Bin>
Modifier and Type | Class and Description |
---|---|
class |
Histogram.Bin
Represents a bin in the Histogram.
|
Constructor and Description |
---|
Histogram()
Constructs a new Histogram with default bin and value labels.
|
Histogram(java.util.Comparator<K> comparator)
Constructs a new Histogram that'll use the supplied comparator to sort keys.
|
Histogram(Histogram<K> in)
Copy constructor for a histogram.
|
Histogram(java.lang.String binLabel,
java.lang.String valueLabel)
Constructs a new Histogram with supplied bin and value labels.
|
Histogram(java.lang.String binLabel,
java.lang.String valueLabel,
java.util.Comparator<K> comparator)
Constructor that takes labels for the bin and values and a comparator to sort the bins.
|
Modifier and Type | Method and Description |
---|---|
void |
addHistogram(Histogram<K> addHistogram)
Mutable method that allows the addition of a Histogram into the current one.
|
Histogram<K> |
divideByHistogram(Histogram<K> divisorHistogram)
Immutable method that divides the current Histogram by an input Histogram and generates a new one
Throws an exception if the bins don't match up exactly
|
boolean |
equals(java.lang.Object o)
Checks that the labels and values in the two histograms are identical.
|
double |
estimateSdViaMad()
Returns a value that is intended to estimate the mean of the distribution, if the distribution is
essentially normal, by using the median absolute deviation to remove the effect of
erroneous massive outliers.
|
java.lang.String |
getBinLabel() |
double |
getCount() |
double |
getCumulativeProbability(double v)
Returns the cumulative probability of observing a value <= v when sampling the
distribution represented by this histogram.
|
double |
getGeometricMean()
Gets the geometric mean of the distribution.
|
double |
getMax() |
double |
getMean() |
double |
getMeanBinSize()
Calculates the mean bin size
|
double |
getMedian() |
double |
getMedianAbsoluteDeviation()
Gets the median absolute deviation of the distribution.
|
double |
getMedianBinSize()
Calculates the median bin size
|
double |
getMin() |
double |
getMode()
Returns id of the Bin that's the mode of the distribution (i.e.
|
double |
getPercentile(double percentile)
Gets the bin in which the given percentile falls.
|
double |
getStandardDeviation() |
double |
getStandardDeviationBinSize(double mean)
Calculates the standard deviation of the bin size
|
double |
getSum()
Returns the sum of the products of the histgram bin ids and the number of entries in each bin.
|
double |
getSumOfValues()
Returns the sum of the number of entries in each bin.
|
java.lang.String |
getValueLabel() |
void |
increment(K id)
Increments the value in the designated bin by 1.
|
void |
increment(K id,
double increment)
Increments the value in the designated bin by the supplied increment.
|
void |
prefillBins(K... ids)
Prefill the histogram with the supplied set of bins.
|
void |
setBinLabel(java.lang.String binLabel) |
void |
setValueLabel(java.lang.String valueLabel) |
void |
trimByTailLimit(int tailLimit)
Trims the histogram when the bins in the tail of the distribution contain fewer than mode/tailLimit items
|
void |
trimByWidth(int width)
Trims the histogram so that only bins <= width are kept.
|
ceilingEntry, ceilingKey, clear, clone, comparator, containsKey, containsValue, descendingKeySet, descendingMap, entrySet, firstEntry, firstKey, floorEntry, floorKey, get, headMap, headMap, higherEntry, higherKey, keySet, lastEntry, lastKey, lowerEntry, lowerKey, navigableKeySet, pollFirstEntry, pollLastEntry, put, putAll, remove, size, subMap, subMap, tailMap, tailMap, values
public Histogram()
public Histogram(java.lang.String binLabel, java.lang.String valueLabel)
public Histogram(java.util.Comparator<K> comparator)
public Histogram(java.lang.String binLabel, java.lang.String valueLabel, java.util.Comparator<K> comparator)
public void prefillBins(K... ids)
public void increment(K id)
public void increment(K id, double increment)
public java.lang.String getBinLabel()
public void setBinLabel(java.lang.String binLabel)
public java.lang.String getValueLabel()
public void setValueLabel(java.lang.String valueLabel)
public boolean equals(java.lang.Object o)
equals
in interface java.util.Map<K extends java.lang.Comparable,Histogram.Bin>
equals
in class java.util.AbstractMap<K extends java.lang.Comparable,Histogram.Bin>
public double getMean()
public double getSum()
public double getSumOfValues()
public double getStandardDeviation()
public double getMeanBinSize()
public double getMedianBinSize()
public double getStandardDeviationBinSize(double mean)
public double getPercentile(double percentile)
percentile
- a value between 0 and 1public double getCumulativeProbability(double v)
public double getMedian()
public double getMedianAbsoluteDeviation()
public double estimateSdViaMad()
public double getMode()
public double getMin()
public double getMax()
public double getCount()
public double getGeometricMean()
public void trimByTailLimit(int tailLimit)
public void trimByWidth(int width)
public Histogram<K> divideByHistogram(Histogram<K> divisorHistogram) throws java.lang.IllegalArgumentException
divisorHistogram
- java.lang.IllegalArgumentException