#include <mc_filter/ExponentialMovingAverage.h>
Public Member Functions | |
ExponentialMovingAverage (double dt, double timeConstant, const VectorT &initValue=VectorT::Zero()) | |
void | append (const VectorT &value) |
const VectorT & | eval () const |
void | saturation (double limit) |
void | reset (const VectorT &initVal) |
double | timeConstant () const |
void | timeConstant (double T) |
Protected Attributes | |
VectorT | average_ = VectorT::Zero() |
double | alpha_ |
double | dt_ |
double | timeConstant_ |
double | saturation_ = -1. |
Exponential Moving Average.
This filter can be seen as an integrator:
\[ y(t) = \frac{1}{T} \int_{u=0}^t x(u) e^{(u - t) / T} {\rm d}{\tau} \]
with T > 0 a reset period acting as anti-windup. It can also (informally) be interpreted as the average value of the input signal x(t) over the last T seconds. Formally, it represents the amount of time for the smoothed response of a unit input to reach 1-1/e (~63%) of the original signal.
See https://en.wikipedia.org/wiki/Exponential_smoothing. It is equivalent to a low-pass filter https://en.wikipedia.org/wiki/Low-pass_filter applied to the integral of the input signal.
Expects type VectorT to have:
|
inline |
Constructor.
dt | Time in [s] between two readings. |
timeConstant | Informally, length of the recent-past window, in [s]. |
initValue | Initial value of the output average. |
|
inline |
Append a new reading to the series.
value | New value. |
|
inline |
Evaluate the smoothed statistic.
|
inline |
Reset average to provided value.
initVal | initial value of the average |
|
inline |
Set output saturation; disable by providing a negative value.
limit | Output will saturate between -limit and +limit. |
|
inline |
Get time constant of the filter.
|
inline |
Update time constant.
T | New time constant of the filter. |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |