Numerical experiments, Tips, Tricks and Gotchas

# 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): $$m_{k}=\frac{S_{k}}{N_{k}}$$ Here $$S_{k} = \sum_{i=1}^{k} w_{k,i} x_{i} \label{eq:sk}$$ $$N_{k} = \sum_{i=1}^{k} w_{k,i} \label{eq:nk}$$ and $$w_{k,i} = 1 \mbox{ for MA} \label{eq:wma}\\$$ $$w_{k,i} = \lambda^{k-i} \mbox{for EWMA} \label{eq:wewma}$$ 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}). $$N_{k} = k$$ 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: $$N_{k}= 1+\lambda+\lambda^{2}+\cdots+\lambda^{k-1}= \frac{1-\lambda^{k}}{1-\lambda}=\frac{1-\lambda^{k}}{\alpha}\label{eq:norm}$$ This norm accounts for 100 % of all weights. At sufficiently large $k$ $$\frac{1}{N_{k}}\rightarrow\frac{1}{N_{\infty}}=\alpha\label{eq:norminf}$$ While definition (\ref{eq:norm}) is intuitive, historically the smoothing period, $P$, for exponential smoothing (\ref{eq:wewma}) is introduced as [2]: $$\alpha=\frac{2}{P+1}$$ These two definitions are related as $$N_{k}=\frac{P+1}{2}\left[1-\left(\frac{P-1}{P+1}\right)^{k}\right]\approx\frac{P+1}{2}$$ In RiskMetrics [4] the effective averaging length $L$ is defined as $$\frac{N_{L}}{N_{\infty}}=0.999=1-\epsilon$$ Therefore \begin{eqnarray*} 1-\lambda^{L} & = & 1-\epsilon\\ \lambda^{L} & = & \epsilon \end{eqnarray*} or $$\lambda=\epsilon^{\frac{1}{L}}$$ This length is related to the natural length as $$L=\frac{ln(\epsilon)}{ln(\lambda)} = \frac{ln(\epsilon)}{ln(1-\frac{1}{N_{\infty}})} \approx 6.9\; N_{\infty}$$

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.