Spring Integration

org.springframework.integration.monitor
Class ExponentialMovingAverage

java.lang.Object
  extended by org.springframework.integration.monitor.ExponentialMovingAverage

public class ExponentialMovingAverage
extends java.lang.Object

Cumulative statistics for a series of real numbers with higher weight given to recent data but without storing any history. Clients call append(double) every time there is a new measurement, and then can collect summary statistics from the convenience getters (e.g. getStatistics()). Older values are given exponentially smaller weight, with a decay factor determined by a "window" size chosen by the caller. The result is a good approximation to the statistics of the series but with more weight given to recent measurements, so if the statistics change over time those trends can be approximately reflected.

Since:
2.0
Author:
Dave Syer

Constructor Summary
ExponentialMovingAverage(int window)
          Create a moving average accumulator with decay lapse window provided.
 
Method Summary
 void append(double value)
          Add a new measurement to the series.
 int getCount()
           
 double getMax()
           
 double getMean()
           
 double getMin()
           
 double getStandardDeviation()
           
 Statistics getStatistics()
           
 void reset()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExponentialMovingAverage

public ExponentialMovingAverage(int window)
Create a moving average accumulator with decay lapse window provided. Measurements older than this will have smaller weight than 1/e.

Parameters:
window - the exponential lapse window (number of measurements)
Method Detail

reset

public void reset()

append

public void append(double value)
Add a new measurement to the series.

Parameters:
value - the measurement to append

getCount

public int getCount()
Returns:
the number of measurements recorded

getMean

public double getMean()
Returns:
the mean value

getStandardDeviation

public double getStandardDeviation()
Returns:
the approximate standard deviation

getMax

public double getMax()
Returns:
the maximum value recorded (not weighted)

getMin

public double getMin()
Returns:
the minimum value recorded (not weighted)

getStatistics

public Statistics getStatistics()
Returns:
summary statistics (count, mean, standard deviation etc.)

toString

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

Spring Integration