com.aelitis.azureus.core.util.average
Class ExponentialMovingAverage

java.lang.Object
  extended by com.aelitis.azureus.core.util.average.ExponentialMovingAverage
All Implemented Interfaces:
Average

public class ExponentialMovingAverage
extends Object
implements Average

Implements an exponential moving average.


Constructor Summary
ExponentialMovingAverage(float weight)
          Create a new exponential moving average, using the given smoothing rate weight.
ExponentialMovingAverage(int periods)
          Create a new exponential moving average which smooths over the given number of periods.
 
Method Summary
 double getAverage()
          Return average-so-far.
 void reset()
          sets back to start-of-day
 double update(double newValue)
          Update average and return average-so-far.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExponentialMovingAverage

public ExponentialMovingAverage(int periods)
Create a new exponential moving average which smooths over the given number of periods.


ExponentialMovingAverage

public ExponentialMovingAverage(float weight)
Create a new exponential moving average, using the given smoothing rate weight.

Method Detail

reset

public void reset()
Description copied from interface: Average
sets back to start-of-day

Specified by:
reset in interface Average

update

public double update(double newValue)
Update average and return average-so-far.

Specified by:
update in interface Average

getAverage

public double getAverage()
Return average-so-far.

Specified by:
getAverage in interface Average