net.sf.jagg
Class CorrelationAggregator

java.lang.Object
  extended by net.sf.jagg.Aggregator
      extended by net.sf.jagg.TwoPropAggregator
          extended by net.sf.jagg.CorrelationAggregator

public class CorrelationAggregator
extends TwoPropAggregator

This class represents the "coefficient of correlation" aggregator over two sets of numeric values.

Since:
0.1.0
Author:
Randy Gettman

Field Summary
 
Fields inherited from class net.sf.jagg.Aggregator
PROP_SELF
 
Constructor Summary
CorrelationAggregator(java.lang.String properties)
          Constructs a CorrelationAggregator on the specified properties, in the format: property, property2.
CorrelationAggregator(java.lang.String property, java.lang.String property2)
          Constructs a CorrelationAggregator that operates on the specified properties.
 
Method Summary
 void init()
          Initialize the internal aggregators: a CovarianceAggregator, and 2 VarianceAggregators (one each for both properties).
 void iterate(java.lang.Object value)
          Iterate the internal aggregators.
 void merge(Aggregator agg)
          Merge the given Aggregator into this one by merging each individual internal Aggregator.
 CorrelationAggregator replicate()
          Returns an uninitialized copy of this Aggregator object, with the same property(ies) to analyze.
 java.lang.Double terminate()
          Return the coefficient of correlation, calculated as follows:
CovariancePop(prop1, prop2) / Math.sqrt(VariancePop(prop1) * VariancePop(prop2))
 DoubleDouble terminateDoubleDouble()
          Return the result as a DoubleDouble.
 
Methods inherited from class net.sf.jagg.TwoPropAggregator
getProperty2, setProperty, toString
 
Methods inherited from class net.sf.jagg.Aggregator
equals, getAggregator, getAggregator, getProperty, getValueFromProperty, hashCode, isInUse, setInUse
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CorrelationAggregator

public CorrelationAggregator(java.lang.String properties)
Constructs a CorrelationAggregator on the specified properties, in the format: property, property2.

Parameters:
properties - A specification string in the format: property, property2.

CorrelationAggregator

public CorrelationAggregator(java.lang.String property,
                             java.lang.String property2)
Constructs a CorrelationAggregator that operates on the specified properties.

Parameters:
property - Correlate this property with the other.
property2 - Correlate this property with the other.
Method Detail

replicate

public CorrelationAggregator replicate()
Returns an uninitialized copy of this Aggregator object, with the same property(ies) to analyze.

Specified by:
replicate in class Aggregator
Returns:
An uninitialized copy of this Aggregator object.

init

public void init()
Initialize the internal aggregators: a CovarianceAggregator, and 2 VarianceAggregators (one each for both properties).

Specified by:
init in class Aggregator
See Also:
CovarianceAggregator, VarianceAggregator

iterate

public void iterate(java.lang.Object value)
Iterate the internal aggregators.

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 by merging each individual internal Aggregator.

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

terminate

public java.lang.Double terminate()
Return the coefficient of correlation, calculated as follows:
CovariancePop(prop1, prop2) / Math.sqrt(VariancePop(prop1) * VariancePop(prop2))

Specified by:
terminate in class Aggregator
Returns:
The coefficient of correlation as a Double.

terminateDoubleDouble

public 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:
The coefficient of correlation as a DoubleDouble, or NaN if no values have been accumulated or the variance for one of the properties is zero.
Since:
0.4.0
See Also:
DoubleDouble


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