Package org.datanucleus.management
Class AbstractStatistics.SMA
java.lang.Object
org.datanucleus.management.AbstractStatistics.SMA
- Enclosing class:
AbstractStatistics
Simple Moving Average
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble
compute
(double value) Compute the moving average.double
-
Field Details
-
values
-
length
private int length -
sum
private double sum -
average
private double average
-
-
Constructor Details
-
SMA
public SMA(int length) - Parameters:
length
- the maximum length
-
-
Method Details
-
currentAverage
public double currentAverage() -
compute
public double compute(double value) Compute the moving average. Synchronised so that no changes in the underlying data is made during calculation.- Parameters:
value
- The value- Returns:
- The average
-