|
tzutrader
A composable C++ backtesting library for trading strategies (experimental)
|
#include <indicators.h>
Public Member Functions | |
| MVar (size_t window_size, size_t dof) | |
| double | get () const noexcept |
| double | update (double value) |
Moving Variance (MVar)
Calculates the variance of the most recent N values. Returns NaN until enough values have been added to fill the window. Once the window is full, it calculates the variance using the formula:
Variance = (1 / (N - dof)) * sum((x_i - mean)^2)
where dof is the degrees of freedom, which is typically 1 for sample variance and 0 for population variance. The N template parameter specifies the size of the window.
The standard deviation can be obtained by taking the square root of the variance.
|
inline |
|
inlinenoexcept |
|
inline |