com.flaptor.hist4j
Class AdaptiveHistogram
- java.lang.Object
-
- com.flaptor.hist4j.AdaptiveHistogram
-
- All Implemented Interfaces:
- java.io.Serializable
- Direct Known Subclasses:
- H1DA
public class AdaptiveHistogram extends java.lang.Object implements java.io.SerializableThis class implements a histogram that adapts to an unknown data distribution. It keeps a more or less constant resolution throughout the data range by increasing the resolution where the data is more dense. For example, if the data has such such a distribution that most of the values lie in the 0-5 range and only a few are in the 5-10 range, the histogram would adapt and assign more counting buckets to the 0-5 range and less to the 5-10 range. This implementation provides a method to obtain the accumulative density function for a given data point, and a method to obtain the data point that splits the data set at a given percentile.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description AdaptiveHistogram()Class constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddValue(float value)Adds a data point to the histogram.longgetAccumCount(float value)Returns the cumulative density function for a given data point.longgetCount(float value)Returns the number of data points stored in the same bucket as a given value.floatgetValueForPercentile(int percentile)Returns the data point that splits the data set at a given percentile.voidnormalize(float targetMin, float targetMax)Normalizes all the values to the desired range.voidreset()Erases all data from the histogram.voidshow()Shows the histograms' underlying data structure.java.util.ArrayList<Cell>toTable()Return a table representing the data in this histogram.
-
-
-
Method Detail
-
reset
public void reset()
Erases all data from the histogram.
-
addValue
public void addValue(float value)
Adds a data point to the histogram.- Parameters:
value- the data point to add.
-
getCount
public long getCount(float value)
Returns the number of data points stored in the same bucket as a given value.- Parameters:
value- the reference data point.- Returns:
- the number of data points stored in the same bucket as the reference point.
-
getAccumCount
public long getAccumCount(float value)
Returns the cumulative density function for a given data point.- Parameters:
value- the reference data point.- Returns:
- the cumulative density function for the reference point.
-
getValueForPercentile
public float getValueForPercentile(int percentile)
Returns the data point that splits the data set at a given percentile.- Parameters:
percentile- the percentile at which the data set is split.- Returns:
- the data point that splits the data set at the given percentile.
-
normalize
public void normalize(float targetMin, float targetMax)Normalizes all the values to the desired range.- Parameters:
targetMin- the target new minimum value.targetMax- the target new maximum value.
-
show
public void show()
Shows the histograms' underlying data structure.
-
toTable
public java.util.ArrayList<Cell> toTable()
Return a table representing the data in this histogram. Each element is a table cell containing the range limit values and the count for that range.
-
-
DMelt 3.0 © DataMelt by jWork.ORG