CBOE Emulator
1.0
|
A structure for calculating an exponential moving variance. More...
#include <exponential_moving_variance.hpp>
Public Member Functions | |
ExponentialMovingVariance (T alpha_, T observation=0) | |
Initialize an exponential moving variance with given \(\alpha\) and \(o_0\). More... | |
void | reset (T observation=0) |
Reset the average to initial state \({\mu}_0\) with observation \(o_0\). The initial variance \({\sigma^2}_0\) is 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... | |
T | process (T observation) |
Calculate the next average \({\mu}_t\) and variance \({\sigma^2}_t\) based on observation \(o_t\). More... | |
T | get_average () const |
Return the current value of the exponential moving average \({\mu}_t\). More... | |
T | get_variance () const |
Return the current value of the exponential moving variance \({\sigma^2}_t\). More... | |
T | get_stddev () const |
Return the current value of the exponential moving standard deviation \({\sigma}_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 variance.
T | the type for the exponential moving average/variance |
The change in value between the current average \({\mu}_{t-1}\) and next observation \(o_t\) for event \(t\) is defined as \(\delta_t\):
\[ \delta_t \gets o_t - {\mu}_{t-1} \]
The exponential moving average \({\mu}_t\) for event \(t\), corresponding change \(\delta_t\), initial observation \(o_0\), and rate of change parameter \(\alpha\) is defined as:
\[ {\mu}_t \gets {\mu}_{t - 1} + \alpha \cdot \delta_t | {\mu}_0 = o_0 \]
The exponential moving variance \({\sigma}^2_t\) for event \(t\), corresponding change \(\delta_t\), and rate of change parameter \(\alpha\) is defined as:
\[ {\sigma^2}_t \gets (1 - \alpha) \cdot ({\sigma^2}_{t-1} + \alpha \cdot \delta^2_t) | {\sigma^2_0} = 0 \]
where:
|
inlineexplicit |
Initialize an exponential moving variance 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 |
Return the current value of the exponential moving standard deviation \({\sigma}_t\).
|
inline |
Return the current value of the exponential moving variance \({\sigma^2}_t\).
|
inline |
Calculate the next average \({\mu}_t\) and variance \({\sigma^2}_t\) based on observation \(o_t\).
observation | the observation \(o_t\) to integrate into the average and variance |
|
inline |
Reset the average to initial state \({\mu}_0\) with observation \(o_0\). The initial variance \({\sigma^2}_0\) is 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 |