Qualia  0.2
Public Member Functions | Private Attributes | List of all members
MovingAverage Class Reference

#include <MovingAverage.h>

Public Member Functions

 MovingAverage (float startValue, float alphaOrN)
 
void update (float v)
 
float get () const
 
void reset (float startValue)
 

Private Attributes

float _alpha
 
float _value
 

Constructor & Destructor Documentation

MovingAverage::MovingAverage ( float  startValue,
float  alphaOrN 
)
inline

Constructs the moving average, starting with #startValue# as its value. The #alphaOrN# argument has two options:

  • if <= 1 then it's used directly as the alpha value
  • if > 1 then it's used as the "number of items that are considered from the past" (*) (*) Of course this is an approximation. It actually sets the alpha value to 2 / (n - 1)

Member Function Documentation

float MovingAverage::get ( ) const
inline

Returns the value of the moving average.

void MovingAverage::reset ( float  startValue)
inline

Resets the moving average to #startValue#.

void MovingAverage::update ( float  v)
inline

Updates the moving average with new value #v#.

Member Data Documentation

float MovingAverage::_alpha
private
float MovingAverage::_value
private

The documentation for this class was generated from the following file: