springs.util
Class IncrementalAverageComputator

java.lang.Object
  |
  +--springs.util.IncrementalAverageComputator

public class IncrementalAverageComputator
extends java.lang.Object

Note: inspired by: http://www.cs.ualberta.ca/~sutton/book/ebook/node19.html Chapter 2.5 "Incremental Implementation" of: "Reinforcement Learning: An Introduction" by: Richard S. Sutton and Andrew G. Barto A Bradford Book The MIT Press Cambridge, Massachusetts London, England


Field Summary
private  double _averageSoFar
           
private  long _numSamples
           
private  double _totalAccumulatedValue
           
 
Constructor Summary
IncrementalAverageComputator()
           
 
Method Summary
 void addSample(double sample)
          Adds a sample to the average.
 double getAverage()
          Gets the average so far.
 double getTotalAccumulatedValue()
          Gets the total accumulated value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_numSamples

private long _numSamples

_averageSoFar

private double _averageSoFar

_totalAccumulatedValue

private double _totalAccumulatedValue
Constructor Detail

IncrementalAverageComputator

public IncrementalAverageComputator()
Method Detail

addSample

public void addSample(double sample)
Adds a sample to the average.

Parameters:
sample - the sample.

getAverage

public double getAverage()
Gets the average so far.

Returns:
the average.

getTotalAccumulatedValue

public double getTotalAccumulatedValue()
Gets the total accumulated value.

Returns:
the total accumulated value.