C# Class Drew.Util.MovingAverageCalculator

Calculates a moving average value over a specified window. The window size must be specified upon creation of this object.
Authored by Drew Noakes, February 2005. Use freely, though keep this message intact and report any bugs to me. I also appreciate seeing extensions, or simply hearing that you're using these classes. You may not copyright this work, though may use it in commercial/copyrighted works. Happy coding. Updated 29 March 2007. Added a Reset() method.
Afficher le fichier Open project: perky/JC2-GPS

Méthodes publiques

Méthode Description
MovingAverageCalculator ( int windowSize ) : System

Create a new moving average calculator.

NextValue ( float nextValue ) : float

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.

Reset ( ) : void

Clears any accumulated state and resets the calculator to its initial configuration. Calling this method is the equivalent of creating a new instance.

Method Details

MovingAverageCalculator() public méthode

Create a new moving average calculator.
If windowSize less than one.
public MovingAverageCalculator ( int windowSize ) : System
windowSize int The maximum number of values to be considered /// by this moving average calculation.
Résultat System

NextValue() public méthode

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.
If nextValue is equal to float.NaN.
public NextValue ( float nextValue ) : float
nextValue float The next value to be considered within the moving average.
Résultat float

Reset() public méthode

Clears any accumulated state and resets the calculator to its initial configuration. Calling this method is the equivalent of creating a new instance.
public Reset ( ) : void
Résultat void