com.flaptor.hist4j
Class HistogramForkNode
- java.lang.Object
-
- com.flaptor.hist4j.HistogramNode
-
- com.flaptor.hist4j.HistogramForkNode
-
- All Implemented Interfaces:
- java.io.Serializable
public class HistogramForkNode extends HistogramNode
The HistogramForkNode splits the data range in two at a given value, pointing to two subtrees, one for values smaller than the split value, and one for values larger than the split value. It implements the recursive calls necesary to obtain the data from the tree structure.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description HistogramForkNode(float splitValue, HistogramNode left, HistogramNode right)Creates a fork node with the given split value and subtrees.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description HistogramNodeaddValue(AdaptiveHistogram root, float value)Adds a value to the histogram by recursively adding the value to either subtree, depending on the split value.voidapply(com.flaptor.hist4j.AdaptiveHistogram.ValueConversion valueConversion)Applies a convertion function to the values stored in 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.java.lang.FloatgetValueForAccumCount(long[] accumCount)Returns the data point where the running cumulative count reaches the target cumulative count.voidreset()Clears the fork node, recursively erasing the subtrees.voidshow(int level)Prints the data for the nodes in its subtrees.voidtoTable(java.util.ArrayList<Cell> table)Build the table representing the histogram data adding the data from each subtree.
-
-
-
Constructor Detail
-
HistogramForkNode
public HistogramForkNode(float splitValue, HistogramNode left, HistogramNode right)Creates a fork node with the given split value and subtrees.- Parameters:
splitValue- the value that splits both subtrees.left- the left subtree.right- the right subtree.
-
-
Method Detail
-
reset
public void reset()
Clears the fork node, recursively erasing the subtrees.- Specified by:
resetin classHistogramNode
-
addValue
public HistogramNode addValue(AdaptiveHistogram root, float value)
Adds a value to the histogram by recursively adding the value to either subtree, depending on the split value.- Specified by:
addValuein classHistogramNode- Parameters:
root- a reference to the adaptive histogram instance that uses this structure.value- the value for which the count is to be incremented.- Returns:
- A reference to itself.
-
getCount
public long getCount(float value)
Returns the number of data points stored in the same bucket as a given value.- Specified by:
getCountin classHistogramNode- 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.- Specified by:
getAccumCountin classHistogramNode- Parameters:
value- the reference data point.- Returns:
- the cumulative density function for the reference point.
-
getValueForAccumCount
public java.lang.Float getValueForAccumCount(long[] accumCount)
Returns the data point where the running cumulative count reaches the target cumulative count.- Specified by:
getValueForAccumCountin classHistogramNode- Parameters:
accumCount- accumCount[0] the running cumulative count. accumCount[1] the target cumulative count.- Returns:
- the data point where the running cumulative count reaches the target cumulative count.
-
apply
public void apply(com.flaptor.hist4j.AdaptiveHistogram.ValueConversion valueConversion)
Applies a convertion function to the values stored in the histogram.- Specified by:
applyin classHistogramNode- Parameters:
valueConversion- a class that defines a function to convert the value.
-
show
public void show(int level)
Prints the data for the nodes in its subtrees.- Specified by:
showin classHistogramNode- Parameters:
level- the level of this node in the tree.
-
toTable
public void toTable(java.util.ArrayList<Cell> table)
Build the table representing the histogram data adding the data from each subtree.- Specified by:
toTablein classHistogramNode
-
-
DMelt 3.0 © DataMelt by jWork.ORG