Break down Simple Moving Average formula

1.2k Views Asked by At

I am new to Mathematics and understanding formulas - I'm currently trying to break down the Simple Moving Average formula from Wikipedia but struggling.

I understand in practice how to calculate it, but I am struggling to really grasp an understanding of the formula below:

$\displaystyle\overline p_{\displaystyle{SM}}=\frac{p_{\displaystyle{M}}+p_{\displaystyle{M}-1}+\cdots+p_{\displaystyle{M}-\displaystyle(n-1)}}{n}=\frac{1}{n}\sum_{i=0}^{n-1}p_{\displaystyle{M}}-i$

Could somebody break this formula down for me and explain it piece by piece? Preferably in both English and Math so I can piece the two together.

2

There are 2 best solutions below

2
On

You are looking at the simple moving average with window length of $n$. This formula is relevant to variable that forms a sequence. Meaning the quantity that you are studying should have some sense of order in it. For example stock prices, temperature during the day, from such series.

So simply speaking you have a sequence $(p_k)$ where $k$ is a natural number $1,2,3,...$

SMA of window $n$ is defined for the sequence $(p_k)$ for all values of $k\ge n$. Now basically you take sum of $n-1$ past values and the current value and divide by $n$ to get the moving average.

Tell me if any of this is not clear.

0
On

Think of the indices as time periods. For example, M could be month 50, or day 300. n represents the number of periods you wish to use to compute the average. For example, with monthly periods you might want to use n = 12 to get an average over the last year.

In the monthly example, pM is then the value of the observation in time period M = 50, and pM - (n - 1) is the value of the observation in time period 50 - (12 - 1) = 50 - 11 = 39. So you sum up the observations in time periods 39 to 50 and divide by the number of observations, which is just a simple average of the last 12 months.

The words "moving" in simple moving average comes from the fact that M moves forward with time, so when next month rolls around, M becomes 51 and you sum up the periods from 40 to 51 and divide by n, which tends to stay fixed.

Keep in mind that the formula applies to arbitrary time periods (e.g., nanoseconds or millenia) and is not restricted to time series. For example, M could represent a position in space and one may want to analyze an average quantity as position is incremented one unit at a time.