Package com.tdunning.math.stats
Class GroupTree
- java.lang.Object
-
- com.tdunning.math.stats.GroupTree
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Centroid centroid)
Centroid
ceiling(Centroid base)
void
checkBalance()
private int
depth()
Centroid
first()
Centroid
floor(Centroid base)
int
headCount(Centroid base)
long
headSum(Centroid base)
java.util.Iterator<Centroid>
iterator()
Iteratres through all groups in the tree.private java.util.Iterator<Centroid>
iterator(Centroid start)
Iterates through all of the Groups in this tree in ascending order of meansCentroid
last()
void
move(double x, int count, Centroid v, java.lang.Iterable<? extends java.lang.Double> data)
Modify an existing value in the tree subject to the constraint that the change will not alter the ordering of the tree.void
print(int depth)
private void
rebalance()
void
remove(Centroid base)
private void
rotate(GroupTree a, GroupTree b, GroupTree c, GroupTree d)
int
size()
long
sum()
java.lang.Iterable<Centroid>
tailSet(Centroid start)
-
-
-
Method Detail
-
add
public void add(Centroid centroid)
-
move
public void move(double x, int count, Centroid v, java.lang.Iterable<? extends java.lang.Double> data)
Modify an existing value in the tree subject to the constraint that the change will not alter the ordering of the tree.- Parameters:
x
- New value to add to Centroidcount
- Weight of new valuev
- The value to modifydata
- The recorded data
-
rebalance
private void rebalance()
-
depth
private int depth()
-
size
public int size()
-
headCount
public int headCount(Centroid base)
- Returns:
- the number of items strictly before the current element
-
headSum
public long headSum(Centroid base)
- Returns:
- the sum of the size() function for all elements strictly before the current element.
-
first
public Centroid first()
- Returns:
- the first Centroid in this set
-
iterator
public java.util.Iterator<Centroid> iterator()
Iteratres through all groups in the tree.- Specified by:
iterator
in interfacejava.lang.Iterable<Centroid>
-
iterator
private java.util.Iterator<Centroid> iterator(Centroid start)
Iterates through all of the Groups in this tree in ascending order of means- Parameters:
start
- The place to start this subset. Remember that Groups are ordered by mean *and* id.- Returns:
- An iterator that goes through the groups in order of mean and id starting at or after the specified Centroid.
-
remove
public void remove(Centroid base)
-
last
public Centroid last()
-
ceiling
public Centroid ceiling(Centroid base)
- Returns:
- the smallest element greater than or equal to base.
-
tailSet
public java.lang.Iterable<Centroid> tailSet(Centroid start)
- Returns:
- the subset of elements equal to or greater than base.
-
sum
public long sum()
-
checkBalance
public void checkBalance()
-
print
public void print(int depth)
-
-