public class MovingAverage extends Object
Constructor and Description |
---|
MovingAverage(double alpha)
Constructor.
|
MovingAverage(double alpha,
double initialValue)
Constructor with initial value.
|
Modifier and Type | Method and Description |
---|---|
void |
add(double value)
Add a value to the moving average.
|
double |
get()
Get the current average.
|
public MovingAverage(double alpha)
alpha
- averaging parameterIllegalArgumentException
- if alpha
is not a finite number in the range 0.0 to 1.0 (inclusive)public MovingAverage(double alpha, double initialValue)
alpha
- averaging parameterinitialValue
- initial valueIllegalArgumentException
- if alpha
is not a finite number in the range 0.0 to 1.0 (inclusive)IllegalArgumentException
- if initialValue
is not a finite numberpublic double get()
Double.NaN
if no values have been added yet.public void add(double value)
value
- value to addIllegalArgumentException
- if value
is not a finite numberCopyright © 2022. All rights reserved.