# A simpler way to calculate Exponentially Weighted Moving Average?

Proposed Method:

Given a time series $x_i$, I want to compute a weighted moving average with an averaging window of $N$ points, where the weightings favour more recent values over older values.

In choosing the weights, I am using the familiar fact that a geometric series converges to 1, i.e. $\sum (\frac{1}{2})^k$, provided infinitely many terms are taken.

To get a discrete number of weights that sum to unity, I am simply taking the first $N$ terms of the geometric series $(\frac{1}{2})^k$, and then normalising by their sum.

When $N=4$, for example, this gives the non-normalised weights

0.0625  0.1250  0.2500  0.5000


which, after normalising by their sum, gives

0.0667  0.1333  0.2667  0.5333


The moving average is then simply the sum of the product of the most recent 4 values against these normalised weights.

This method generalises in the obvious way to moving windows of length $N$, and seems computationally easy as well.

Question:

Is there any reason not to use this simple way to calculate a weighted moving average using 'exponential weights'?

I ask because the Wikipedia entry for EWMA seems more complicated. Which makes me wonder whether the textbook definition of EWMA perhaps has some statistical properties that the above simple definition does not? Or are they in fact equivalent?

-

I've found that computing exponetially weighted running averages using $\overline{x} \leftarrow \overline{x} + \alpha (x - \overline{x})$, $\alpha<1$ is
• that is easily, if only approximately, interpretable in terms of an "effective number of samples" $N=\alpha^{-1}$ (compare this form to the form for computing the running average),
Technically, this approach does incorporate all history into the average. The two main advantages to using the full window (as opposed to the truncated one discussed in the question) are that in some cases it can ease analytic characterization of the filtering, and it reduces the fluctuations induced if a very large (or small) data value is part of the data set. For example consider the filter result if the data are all zero except for one datum whose value is $10^6$.
 Hi there. Does the formula you've suggested include all previous values with exponentially diminishing weights? So the entire time-series would be included, not just the most recent $N$ points? Referring to the $N=4$ example posed in the question, are you suggesting setting $\alpha=0.25$ or $\alpha=0.5$ to approximate the 4-point moving average? – AKE Nov 29 '12 at 2:50 Ok, that makes sense. So it seems that in cases where the time series values can be affected by significant short-term transients that have no bearing whatsoever after a certain amount of time has elapsed, it may be advantageous to use the truncated EWMA with $N$ chosen to match this `relevancy' characteristic of historical information. The truncated EWMA in this case would prevent a $10^6$ spike having any impact at all on the result even if it occurred in the recent past, as long as it occured outside the region of information relevancy... Accepting your answer -- thanks! – AKE Nov 29 '12 at 10:33