Home

Recent
Archive

Numerical experiments, Tips, Tricks and Gotchas

Numerically speaking

Effective smoothing length

Simple Moving Average and Exponentially Weighted Average

Both Simple Moving Average (MA) [1] and Exponentially Weighted Moving Average (EWMA) [2] can be described as a ratio of the weighted sum and the norm (see [3] for details): \begin{equation} m_{k}=\frac{S_{k}}{N_{k}} \end{equation} Here \begin{equation} S_{k} = \sum_{i=1}^{k} w_{k,i} x_{i} \label{eq:sk} \end{equation} \begin{equation} N_{k} = \sum_{i=1}^{k} w_{k,i} \label{eq:nk} \end{equation} and \begin{equation} w_{k,i} = 1 \mbox{ for MA} \label{eq:wma}\\ \end{equation} \begin{equation} w_{k,i} = \lambda^{k-i} \mbox{for EWMA} \label{eq:wewma} \end{equation} For the case of EWMA $k \to \infty $.

Effective smoothing length

The smoothing length is well defined in the simple average. It is the norm $N_{k}$ (\ref{eq:nk}). \begin{equation} N_{k} = k \end{equation} which is the number of terms in (\ref{eq:sk}).

The norm with the weights (\ref{eq:wewma}) is a natural generalization of the smoothing length for the exponential average: \begin{equation} N_{k}= 1+\lambda+\lambda^{2}+\cdots+\lambda^{k-1}= \frac{1-\lambda^{k}}{1-\lambda}=\frac{1-\lambda^{k}}{\alpha}\label{eq:norm} \end{equation} This norm accounts for 100 % of all weights. At sufficiently large $k$ \begin{equation} \frac{1}{N_{k}}\rightarrow\frac{1}{N_{\infty}}=\alpha\label{eq:norminf} \end{equation} While definition (\ref{eq:norm}) is intuitive, historically the smoothing period, $P$, for exponential smoothing (\ref{eq:wewma}) is introduced as [2]: \begin{equation} \alpha=\frac{2}{P+1} \end{equation} These two definitions are related as \begin{equation} N_{k}=\frac{P+1}{2}\left[1-\left(\frac{P-1}{P+1}\right)^{k}\right]\approx\frac{P+1}{2} \end{equation} In RiskMetrics [4] the effective averaging length $L$ is defined as \begin{equation} \frac{N_{L}}{N_{\infty}}=0.999=1-\epsilon \end{equation} Therefore \begin{eqnarray*} 1-\lambda^{L} & = & 1-\epsilon\\ \lambda^{L} & = & \epsilon \end{eqnarray*} or \begin{equation} \lambda=\epsilon^{\frac{1}{L}} \end{equation} This length is related to the natural length as \begin{equation} L=\frac{ln(\epsilon)}{ln(\lambda)} = \frac{ln(\epsilon)}{ln(1-\frac{1}{N_{\infty}})} \approx 6.9\; N_{\infty} \end{equation}

In particular, for $\lambda=0.94$ [4], the above definitions give the following values: $L=112$, $P=32$, $N_{\infty}=17$ .  

A couple of specific cases are also worth mentioning. For $N_{\infty}=P=1$ $\lambda=0$ - no averaging; and for $L=1$   $\lambda=0.001$.

The values of all definitions for selected $\lambda$ are collected in the table below [3].

$\lambda$ L P $N_{\infty}$  Comment
0 0 1 1 No averaging
0.001 1 1.002 1.001  
0.5 10 3 2  
0.75 24 7 4  
0.875 52 15 8  
0.94 112 33 17  RiskMetrix

References

  1. Wikipedia: Moving average.
  2. Wikipedia: Exponential smoothing.
  3. N.V.Shokhirev, Moving Average and Exponential Smoothing., www.numericalexpert.com, 2012
  4. Jorge Mina and Jerry Yi Xiao, Return to RiskMetrics: The Evolution of a Standard, RiskMetrics, 2001.

© Nikolai Shokhirev, 2012-2017

email: nikolai(dot)shokhirev(at)gmail(dot)com

Count: