org.apache.mahout.cf.taste.impl.common
Class FullRunningAverage

java.lang.Object
  extended by org.apache.mahout.cf.taste.impl.common.FullRunningAverage
All Implemented Interfaces:
java.io.Serializable, RunningAverage
Direct Known Subclasses:
FullRunningAverageAndStdDev

public class FullRunningAverage
extends java.lang.Object
implements RunningAverage, java.io.Serializable

A simple class that can keep track of a running avearage of a series of numbers. One can add to or remove from the series, as well as update a datum in the series. The class does not actually keep track of the series of values, just its running average, so it doesn't even matter if you remove/change a value that wasn't added.

See Also:
Serialized Form

Constructor Summary
FullRunningAverage()
           
 
Method Summary
 void addDatum(double datum)
           
 void changeDatum(double delta)
           
 double getAverage()
           
 int getCount()
           
 void removeDatum(double datum)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FullRunningAverage

public FullRunningAverage()
Method Detail

addDatum

public void addDatum(double datum)
Specified by:
addDatum in interface RunningAverage
Parameters:
datum - new item to add to the running average

removeDatum

public void removeDatum(double datum)
Specified by:
removeDatum in interface RunningAverage
Parameters:
datum - item to remove to the running average
Throws:
java.lang.IllegalStateException - if count is 0

changeDatum

public void changeDatum(double delta)
Specified by:
changeDatum in interface RunningAverage
Parameters:
delta - amount by which to change a datum in the running average
Throws:
java.lang.IllegalStateException - if count is 0

getCount

public int getCount()
Specified by:
getCount in interface RunningAverage

getAverage

public double getAverage()
Specified by:
getAverage in interface RunningAverage

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.