# FIR Filters and moving average filter

Fir filter confusion

I am trying to get some knowledge about FIR filters. According to above link FIR filter is just the convolution of a sampled input signal to impulse response of a filter. I have done some research and according to some texts FIR is the same as calculating the moving average of the input samples and there is no talk about impulse response. It seems if we take the moving average we can create a filter.

I would appreciate it if someone could help me to understand FIR filter . According to tutorials here we make FIR filter by just delaying the samples .https://greatscottgadgets.com/sdr/10/

• A FIR filter, in general, is not the same as a moving average filter. Can you explain what part of the answer you linked to are you having difficulty understanding? – MBaz Sep 18 '16 at 22:34
• Wouldn't the tap delay line function the same as moving average ? – Jack Sep 18 '16 at 22:37
• @MBaz However you could call a FIR filter a weighted moving average filter, with the weights not having to be positive or normalized in general. – fibonatic Sep 18 '16 at 22:56
• @fibonatic, Yes, that is right, in the case of a very general weighted MA, but in that case you could just say "convolution". – MBaz Sep 18 '16 at 23:20
• If by "moving average" you mean $\displaystyle\frac{1}{N}\sum_{n=0}^{N-1} x[k-n]$ then this is just a very specific FIR filter. If you mean the MA part of ARMA then they are one and the same (an FIR filter is just an MA filter, perhaps with some modification of notation). – Peter K. Sep 19 '16 at 0:40

A FIR filter is (similar to, or) just a weighted moving average filter, where (unlike a typical equally weighted moving average filter) the weights of each delay tap are not constrained to be identical or even of the same sign. By changing various values in the array of weights (the impulse response, or time shifted and sampled version of the same), the frequency response of a FIR filter can be completely changed.

• Thank you but how is the moving average related to the convolution of impulse response to the input of the filter in this equation? I guess this is the general form for any digital filter. So for FIR couple of samples are weigthed averaged and then are convolved with the impulse response? $$y(n)=\sum_{n=0}^{N-1}h(k)x(n-k)\tag{1}$$ – Jack Sep 20 '16 at 3:53
• @MaryannEthan $h[k]$ are actually the weights of averaging. For example, if you assume the $h[n]$ in my answer, then $y[n]=x[n]*h[n]=\sum_{k=0}^{N-1}h[k]x[n-k]=\frac{1}{2}x[n]+\frac{1}{2}x[n-1]$. Note that $N=2$ in this example. – msm Sep 20 '16 at 4:14
• But isn't h[k] an impulse response? – Jack Sep 20 '16 at 4:18
• I guess in your answer impulse response of FIR is the moving average of the pulse input? – Jack Sep 20 '16 at 4:21
• @MaryannEthan please use @ in your comment. I think you have not understood the relationship of impulse response with the input-output transfer function in an LTI system... – msm Sep 22 '16 at 0:30

Moving average (MA), in general, is a procedure to calculate the mean of samples. This can be a simple arithmatic mean (where $N$ samples are added together and the result is divided by $N$) or a more general weighted mean. Now consider the following filter: $$h[n]=\frac{1}{2}\delta[n]+\frac{1}{2}\delta[n-1]$$ This is the impulse response of the filter (input is $\delta[n]$). There are a few points here:

• What ac actually it does is adds the input to a delayed version of it and divides the result by 2.
• The impulse response has finite nonzero taps. Hence, it is a finite impulse response.

Hence, you can conclude that this filter is an FIR which outputs the mean value of the current input sample and the previous.

Note that moving average is a low pass filter. Intuitively, it smooths the sudden changes which is equivalent to attenuating high frequency components.

That said, now consider $$h[n]=\frac{1}{2}\delta[n]-\frac{1}{2}\delta[n-1]$$ which is a high pass filter and has nothing to do with averaging (in its commonly known sense). However, it is FIR.