Class MovingAverageCalculator
- Namespace
- Geotab.Checkmate.ObjectModel.Fuel
- Assembly
- Geotab.Checkmate.ObjectModel.dll
public class MovingAverageCalculator
- Inheritance
-
MovingAverageCalculator
- Inherited Members
Constructors
MovingAverageCalculator(int)
Initializes a new instance of the MovingAverageCalculator class.Create a new moving average calculator.
public MovingAverageCalculator(int window)
Parameters
window
intThe maximum number of values to be considered by this moving average calculation.
Methods
IsMature()
Gets a value indicating whether enough values have been provided to fill the specified window size. Values returned from NextValue may still be used prior to IsMature returning true, however such values are not subject to the intended smoothing effect of the moving average's window size.
public bool IsMature()
Returns
- bool
Whether enough values have been provided to fill the specified window size.
NextValue(double)
Updates the moving average with its next value, and returns the updated average value. When IsMature is true and NextValue is called, a previous value will 'fall out' of the moving average.
public double NextValue(double nextValue)
Parameters
nextValue
doubleThe next value to be considered within the moving average.
Returns
- double
The updated moving average value.
Reset()
Clears any accumulated state and resets the calculator to its initial configuration. Calling this method is the equivalent of creating a new instance.
public void Reset()