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:
Serializable, RunningAverage
Direct Known Subclasses:
FullRunningAverageAndStdDev

public class FullRunningAverage
extends Object
implements RunningAverage, Serializable

A simple class that can keep track of a running average 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()
           
FullRunningAverage(int count, double average)
           
 
Method Summary
 void addDatum(double datum)
           
 void changeDatum(double delta)
           
 double getAverage()
           
 int getCount()
           
 RunningAverage inverse()
           
 void removeDatum(double datum)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FullRunningAverage

public FullRunningAverage()

FullRunningAverage

public FullRunningAverage(int count,
                          double average)
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:
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:
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

inverse

public RunningAverage inverse()
Specified by:
inverse in interface RunningAverage
Returns:
a (possibly immutable) object whose average is the negative of this object's

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.