Package io.pravega.common
Class ExponentialMovingAverage
- java.lang.Object
-
- io.pravega.common.ExponentialMovingAverage
-
public class ExponentialMovingAverage extends java.lang.ObjectProvides an Exponential moving average of some value.
-
-
Constructor Summary
Constructors Constructor Description ExponentialMovingAverage(double initialValue, double newSampleWeight, boolean sqrtWeighting)Creates a new value to track.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doubleaddNewSample(double newSample)Adds a new sample to the moving average and returns the updated value.doublegetCurrentValue()Returns the current moving average.java.lang.StringtoString()
-
-
-
Constructor Detail
-
ExponentialMovingAverage
public ExponentialMovingAverage(double initialValue, double newSampleWeight, boolean sqrtWeighting)Creates a new value to track.- Parameters:
initialValue- The value to be used as the initial averagenewSampleWeight- The fractional weight to give to new samples. 0.0 - 1.0 (exclusive)sqrtWeighting- If the samples should be weighted according to the square root to reduce the impact of outliers.
-
-
Method Detail
-
getCurrentValue
public double getCurrentValue()
Returns the current moving average.- Returns:
- Double indicating the current moving average.
-
addNewSample
public double addNewSample(double newSample)
Adds a new sample to the moving average and returns the updated value.- Parameters:
newSample- the new value to be added- Returns:
- Double indicating the updated moving average value after adding a new sample.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-