FilterDoubleExponentialSmoothing provides an weighted running average filter More...
#include <Filter.h>
Public Member Functions | |
FilterDoubleExponentialSmoothing (double _alpha=0.5, double _gamma=1.0) | |
double | getGamma () |
virtual double | next (double y) |
Update the value. All inherited classes need to update value in next(). | |
double | operator= (double _value) |
void | setGamma (double _gamma) |
Protected Attributes | |
double | gamma |
double | slope |
FilterDoubleExponentialSmoothing provides an weighted running average filter
The FilterDoubleExponentialSmoothing calculates a simple running average for both the average and slope using the weight values alpha and gamma.
value = ((1.0-alpha) * (value + slope)) + (alpha * (double)y); slope = ((1.0-gamma) * (slope)) + (gamma * (value - value_prev));
If the weight values (alpha , gamma) are larger (near 1.0) the formulas react faster for changes and if they are near 0.0 then the reaction is slower. The weight values alpha and gamma may be set in the constructor or with setAlpha() and setGamma() .
alvar::FilterDoubleExponentialSmoothing::FilterDoubleExponentialSmoothing | ( | double | _alpha = 0.5 , |
double | _gamma = 1.0 |
||
) | [inline] |
double alvar::FilterDoubleExponentialSmoothing::getGamma | ( | ) | [inline] |
double alvar::FilterDoubleExponentialSmoothing::next | ( | double | y | ) | [virtual] |
Update the value. All inherited classes need to update value in next().
Reimplemented from alvar::FilterRunningAverage.
Definition at line 99 of file Filter.cpp.
double alvar::FilterDoubleExponentialSmoothing::operator= | ( | double | _value | ) | [inline] |
Reimplemented from alvar::FilterRunningAverage.
void alvar::FilterDoubleExponentialSmoothing::setGamma | ( | double | _gamma | ) | [inline] |
double alvar::FilterDoubleExponentialSmoothing::gamma [protected] |
double alvar::FilterDoubleExponentialSmoothing::slope [protected] |