# 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?

• How did you normalise the sum? Could you describe the method you have choosen? It is not very clear from the post. which, after normalising by their sum, gives 0.0667 0.1333 0.2667 0.5333 – user56797 Oct 1 '14 at 20:30
• To begin with your are assuming 1) that there are no unusual values and no level shifts and no time trends and no seasonal dummies ; 2) that the optimal weighted average has weights that fall on a smooth curve describable by 1 coefficient ; 3) that the error variance is constant ; that there are no known causative series ; Why all of the assumptions ? – IrishStat Oct 1 '14 at 21:18
• @Ravi: In the example given, the sum of the first four terms is 0.9375 = 0.0625+0.125+0.25+0.5. So, the first four terms holds ~93.8% of the total weight (6.2% is in the truncated tail). Use this to obtain normalised weights that sum to unity by rescaling (dividing) by 0.9375. This gives 0.06667, 0.1333, 0.2667, 0.5333. – Assad Ebrahim Oct 1 '14 at 22:21
• @IrishStat It's best not to draw people away from the site in comments or answers, since advice you give offsite is not with the question and so doesn't help later readers (e.g. see reason 1. of the top answer here); if it's suitable advice, it should usually be here. – Glen_b Oct 2 '14 at 18:49
• Detailed explanation of EWMA: mathematical-modeling-python.blogspot.dk/2013/11/… – tashuhka Apr 23 '15 at 11:49

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? – Assad Ebrahim 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! – Assad Ebrahim Nov 29 '12 at 10:33