CBOE Emulator
1.0
|
A structure for calculating an exponential moving average. More...
#include <exponential_moving_average.hpp>
Public Member Functions | |
ExponentialMovingAverage (T alpha_, T observation=0) | |
Initialize an exponential moving average with given \(\alpha\) and \(o_0\). More... | |
void | reset (T observation=0) |
Reset the average to initial state \({\mu}_0\) with observation \(o_0\). More... | |
void | set_alpha (T alpha_) |
Set the \(\alpha\) parameter to a new value. More... | |
T | get_alpha () const |
Return the \(\alpha\) parameter. More... | |
void | process (T observation) |
Calculate the next average \({\mu}_t\) based on observation \(o_t\). More... | |
T | get_average () const |
Return the current value of the exponential moving average \({\mu}_t\). More... | |
Static Public Attributes | |
static constexpr T | ALPHA_MIN = 0 |
the minimal value for alpha to take | |
static constexpr T | ALPHA_MAX = 1 |
the maximal value for alpha to take | |
A structure for calculating an exponential moving average.
T | the type for the exponential moving average |
The exponential moving average \({\mu}_t\) for event \(t\), corresponding observation \(o_t\), initial observation \(o_0\), and rate of change parameter \(\alpha\) is defined as:
\[ {\mu}_t \gets \alpha \cdot o_t + (1 - \alpha) \cdot {\mu}_{t - 1} | {\mu}_0 = o_0\]
where:
|
inlineexplicit |
Initialize an exponential moving average with given \(\alpha\) and \(o_0\).
alpha_ | the \(\alpha\) parameter, i.e., rate of change |
observation | the initial observation \(o_0\) for the average |
|
inline |
Return the \(\alpha\) parameter.
|
inline |
Return the current value of the exponential moving average \({\mu}_t\).
|
inline |
Calculate the next average \({\mu}_t\) based on observation \(o_t\).
observation | the observation \(o_t\) to integrate into the average |
|
inline |
Reset the average to initial state \({\mu}_0\) with observation \(o_0\).
observation | the initial observation \(o_0\) for the average |
|
inline |
Set the \(\alpha\) parameter to a new value.
alpha_ | the \(\alpha\) parameter, i.e., rate of change |