net.sf.jagg
Class AbstractVarianceAggregator

java.lang.Object
  extended by net.sf.jagg.Aggregator
      extended by net.sf.jagg.AbstractVarianceAggregator
Direct Known Subclasses:
StdDevAggregator, StdDevPopAggregator, VarianceAggregator, VariancePopAggregator

public abstract class AbstractVarianceAggregator
extends Aggregator

This abstract class represents variance-like aggregator calculations over numeric values.

Since:
0.3.0
Author:
Randy Gettman

Field Summary
protected  long myCount
          A running count of items processed so far for the given property.
protected  DoubleDouble mySum
          A running total of items processed so far for the given property.
protected  DoubleDouble myVarNumerator
          A running total of the variance, before it is divided by the denominator in the variance calculation.
 
Fields inherited from class net.sf.jagg.Aggregator
PROP_SELF
 
Constructor Summary
AbstractVarianceAggregator(java.lang.String property)
          Constructs an VarianceAggregator that operates on the specified property.
 
Method Summary
 void init()
          Initialize the sum and count to zero.
 void iterate(java.lang.Object value)
          If the property is non-null, then count it and add the property value to the sum.
 void merge(Aggregator agg)
          Merge the given Aggregator into this one.
abstract  DoubleDouble terminateDoubleDouble()
          Return the result as a DoubleDouble.
 
Methods inherited from class net.sf.jagg.Aggregator
equals, getAggregator, getAggregator, getProperty, getValueFromProperty, hashCode, isInUse, replicate, setInUse, setProperty, terminate, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

myCount

protected long myCount
A running count of items processed so far for the given property.


mySum

protected DoubleDouble mySum
A running total of items processed so far for the given property.


myVarNumerator

protected DoubleDouble myVarNumerator
A running total of the variance, before it is divided by the denominator in the variance calculation.

Constructor Detail

AbstractVarianceAggregator

public AbstractVarianceAggregator(java.lang.String property)
Constructs an VarianceAggregator that operates on the specified property.

Parameters:
property - Calculate the variance of this property's values.
Method Detail

init

public void init()
Initialize the sum and count to zero.

Specified by:
init in class Aggregator

iterate

public void iterate(java.lang.Object value)
If the property is non-null, then count it and add the property value to the sum. Update the variance numerator.

Specified by:
iterate in class Aggregator
Parameters:
value - The value to aggregate.
See Also:
Aggregator.getValueFromProperty(java.lang.Object, java.lang.String)

merge

public void merge(Aggregator agg)
Merge the given Aggregator into this one. Add the respective sums and counts together. Update the variance numerator.

Specified by:
merge in class Aggregator
Parameters:
agg - The Aggregator to merge into this one.

terminateDoubleDouble

public abstract DoubleDouble terminateDoubleDouble()
Return the result as a DoubleDouble. This is used mainly when other Aggregators that use this result must maintain a high precision.

Overrides:
terminateDoubleDouble in class Aggregator
Returns:
A DoubleDouble representing the result of the aggregation.
See Also:
DoubleDouble


Copyright © 2010-2013 jAgg Team. All Rights Reserved.