# different moving average filters differences

Suppose we want to use a moving average filter (3-point moving average) for $X[n]$ (where $Y[n]$ is output). What are the differences among

1. $Y[n]=\frac13X[n-1]+\frac13X[n]+\frac13X[n+1]$,
2. $Y[n]=\frac13X[n]+\frac13X[n+1]+\frac13X[n+2]$, and
3. $Y[n]=\frac13X[n]+\frac13X[n-1]+\frac13X[n-2]$ ?

Igoring the causality aspect: The only difference is time shift. You'll get the same waveform for y[n], it is just shifted in time by one or two samples.

• Do you mean all of them (all of $Y[n]$) will be identical (their differences are only in time shift)? – Reza Mahjoob Jan 10 '18 at 6:15
• Yes. You are always averaging over three samples, just over different input time windows. $Y_1[n] = Y_2[n-1] = Y_3[n+1].$ – Hilmar Jan 10 '18 at 18:51
• suppose you want to do a moving average of 10 points on a signal. How about the first initial samples, e.g. sample 1 or 2? I mean we don't have any sample before sample 1 of our signal, the how can we take average? – Reza Mahjoob Jan 13 '18 at 6:47

Hi: All of those moving averages require future values of $X$ which in DSP terminology means that they are non causal filters and physically not realizable. Also, in general you should not have $X[n]$ on both sides of the equation because simplification is then possible and this means that it's no longer an equally weighted filter. So, if you fix that and move the index back one so that you have $Y[n] = 1/3 *(X[n-1] + X[n-2] + X[n-3])$ then that is a causal filter that is realizable.

• I've edited that. What differences are exist other than non-causality? – Reza Mahjoob Jan 8 '18 at 8:00
• The last of the three filters is causal as it doesn't need any future input values. – Matt L. Jan 8 '18 at 8:44
• Hi Matt: I see what you mean, but, atleast In time series-econometrics, one would not use that notation where $Y[n]$ is on the left side and $X[n]$ on the RHS because then it's difficult to say which came first. the X or the Y ? or simultaneously ? But, I see how one could think of that as causal if one calculates the response instantaneously. All the best. – mark leeds Jan 8 '18 at 22:49

The difference is just the choice of values to be averaged. System $1$ computes the average by using two values that are adjacent to the current value. If $n$ is time, then this filter is non-causal because it uses one past and on future value of the input. If $n$ is space (as in image processing), then such a filter is perfectly possible. System $2$ uses the current value and two future values (if $n$ is time) to compute the average; obviously, this filter is also non-causal. If $n$ is space (or something else) then such a filter is of course possible. System $3$ uses the current value and two past values to compute the average and, consequently, it is causal.