org.apache.mahout.cf.taste.impl.common
Class FullRunningAverage
java.lang.Object
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
FullRunningAverage
public FullRunningAverage()
FullRunningAverage
public FullRunningAverage(int count,
double average)
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.