net.sf.jagg
Class LinearRegressionAggregator

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

public class LinearRegressionAggregator
extends TwoPropAggregator

This class represents the "linear regression" aggregator over two sets of numeric values. Many values can be returned by this Aggregator, all encapsulated in the object LinearRegressionStats.

Since:
0.1.0
Author:
Randy Gettman
See Also:
LinearRegressionStats

Field Summary
 
Fields inherited from class net.sf.jagg.Aggregator
PROP_SELF
 
Constructor Summary
LinearRegressionAggregator(java.lang.String properties)
          Constructs a LinearRegressionAggregator on the specified properties, in the format: property, property2.
LinearRegressionAggregator(java.lang.String property, java.lang.String property2)
          Constructs a LinearRegressionAggregator that operates on the specified properties.
 
Method Summary
 void init()
          Initialize the internal aggregators: A CovarianceAggregator, 2 VarianceAggregators (one each for both properties), and 2 AvgAggregators (one each for both properties).
 void iterate(java.lang.Object value)
          If both property values are non-null, then iterate the internal aggregators and increment the count.
 void merge(Aggregator agg)
          Merge the given Aggregator into this one.
 LinearRegressionAggregator replicate()
          Returns an uninitialized copy of this Aggregator object, with the same property(ies) to analyze.
 LinearRegressionStats terminate()
          Return a LinearRegressionStats, with the following calculations: slope = cov(prop1, prop2) / var(prop2) intercept = avg(prop1) - slope * avg(prop2) count = number of pairs where both elements were non-null, and thus counted in these calculations.
 
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, terminateDoubleDouble
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LinearRegressionAggregator

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

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

LinearRegressionAggregator

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

Parameters:
property - Calculate linear regression statistics of this property with the other.
property2 - Calculate linear regression statistics of this property with the other.
Method Detail

replicate

public LinearRegressionAggregator 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, 2 VarianceAggregators (one each for both properties), and 2 AvgAggregators (one each for both properties). Initialize a count to zero.

Specified by:
init in class Aggregator
See Also:
CovariancePopAggregator, VariancePopAggregator, AvgAggregator

iterate

public void iterate(java.lang.Object value)
If both property values are non-null, then iterate the internal aggregators and increment the count.

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 internal counts.

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

terminate

public LinearRegressionStats terminate()
Return a LinearRegressionStats, with the following calculations:

Specified by:
terminate in class Aggregator
Returns:
A LinearRegressionStats.


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