org.jaitools.numeric
Class MeanVarianceProcessor

java.lang.Object
  extended by org.jaitools.numeric.AbstractProcessor
      extended by org.jaitools.numeric.MeanVarianceProcessor
All Implemented Interfaces:
Processor

public class MeanVarianceProcessor
extends AbstractProcessor

A Processor to calculate running mean and variance. The algorithm used is that of Welford (1962) which was presented by Knuth:

Donald E. Knuth (1998). The Art of Computer Programming, volume 2: Seminumerical Algorithms, 3rd edn., p. 232.
The algorithm is described online at:
http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#On-line_algorithm

Since:
1.0
Version:
$Id$
Author:
Michael Bedward
See Also:
Statistic, StreamingSampleStats

Field Summary
 
Fields inherited from class org.jaitools.numeric.AbstractProcessor
numAccepted, numNaN, numNoData, numOffered
 
Constructor Summary
MeanVarianceProcessor()
           
 
Method Summary
 Double get(Statistic stat)
          Gets the value of the statistic calculated by this processor.
 Collection<Statistic> getSupported()
          Gets the Statistics supported by this processor.
protected  boolean update(Double sample)
          Processes a sample value.
 
Methods inherited from class org.jaitools.numeric.AbstractProcessor
addNoDataRange, addNoDataValue, addRange, addRange, get, getNoDataRanges, getNumAccepted, getNumNaN, getNumNoData, getNumOffered, getRanges, getRangesType, isAccepted, offer, setRangesType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MeanVarianceProcessor

public MeanVarianceProcessor()
Method Detail

getSupported

public Collection<Statistic> getSupported()
Gets the Statistics supported by this processor.

Returns:
supported Statistics

update

protected boolean update(Double sample)
Processes a sample value.

Specified by:
update in class AbstractProcessor
Parameters:
sample - the sample value
Returns:
true if the sample is accepted; false otherwise

get

public Double get(Statistic stat)
Gets the value of the statistic calculated by this processor.

Parameters:
stat - the specified statistic
Returns:
the value of the statistic if it has been calculated or Double.NaN otherwise


Copyright © 2009-2013. All Rights Reserved.