1
$\begingroup$

I know it's possible to calculate a regular average incrementally knowing the previous average, the next number and the number of items. But is this possible for a moving average of N items, at least approximately?

To calculate the exact SMA in this case you must know the first number in a set which you're about to leave out, as shown here. That's why I ask about the approximation.

I tried an approach similar to the one for a regular average: multiply the previous average by N - 1, add a new number and then divide by N. But the result looked like garbage to me.

$\endgroup$

1 Answer 1

1
$\begingroup$

You can try $a_{k+1}=ua_k+v x_{k+1}$. This will not produce a true moving average, but instead $x_i$ contributes to $a_n$ with a factor of $v\cdot u^{n-i}$. So if we let $0<u<1$, we will at least have that $x_i$ contributes less and less the "older" it is. We should ensure that $v+vu+vu^2+\ldots=1$, that is $v=1-u$. In contrast to the moving average where the influence of old values breaks off suddnely, this approximation gives as smooth "fade-out". Zis may even be an advantage: A big exceptional spike one year ago will cause a (small) spike today in the one-year moving average, even if nothing happened recently. The approximation will not cause this. Then again, seasonal oscillations do not vanish with this ...

$\endgroup$
1
  • $\begingroup$ It seems I need to experiment with v and u factors here. $\endgroup$
    – pati
    May 23, 2014 at 23:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .