# How to understand the filter coefficients in FIR filter

Here it is the difference equation we have:

y(n) = -0.25x(n) - 0.15x(n − 1) + 0.78x(n − 2) − 0.15x(n − 3) - 0.25x(n - 4)


I understand that is FIR. The coefficients are selected in the way that certain input signal frequencies are removed by such convolution system. Take Matlab audio file gong.mat for example, we read the file then we have input signal x and sampling rate Fs, then through such system, we have output signal y. How do we understand the filter coefficients that make some input signal frequencies are filtered? Different coefficients lead to different filter type? Can we estimate what frequencies are removed?

• figure; freqz(h); where h is the vector of coefficients – ThP Sep 12 '18 at 6:15
• @Thp, any more theory explanation? – Rui Huang Sep 12 '18 at 6:18
• I think this question belongs to math.stackexchange.com. You can also start with en.wikipedia.org/wiki/Finite_impulse_response – NPE Sep 12 '18 at 7:03
• The Fourier transform is the answer. Given the filter coefficients, it computes the frequency response of the system, which tells you how much each frequency is attenuated – Luis Mendo Sep 12 '18 at 8:49
• Too broad. FIR filters are the subject of entire chapter(s) of introductory DSP textbooks. If the question was less broad, dsp.stackexchange might be a better place than math.stackexchange – hotpaw2 Sep 12 '18 at 14:52

2-tap FIR filters can be understood with a simple intuition (I use Python for plotting, but freqz is the same there).

Let's start with two taps with the same value: b = [1, 1]. This lets through constant signals (e.g. [1, 1, 1, ...]) but will more or less block rapidly changing ones (e.g. [1, -1, 1, -1, ...]), i.e. it is a lowpass:

w, h = scipy.signal.freqz([1, 1], 1)

plt.plot(w, abs(h))


On the other hand, b = [-1, 1] will do the opposite: let changing signals pass but block constant ones, i.e., we have a highpass.

w, h = scipy.signal.freqz([-1, 1], 1)

plt.plot(w, abs(h))


I'm not sure it is straightforward to expand this intuition to more complex signals like yours. But looking at the shape, I would expect some band-pass behavior (because we have both high- and lowpass components) with a peak frequency around one third of the sampling frequency (because a signal like [1, 0, 0, -1, 0, 0, 1, ...] will be able to pass). This apparently isn't so far from the truth:

freqz can plot a magnitude and phase of the normalized frequency. use it like this:

freqz(b,1)


where b is a vector of the coefficients.

I agree with NPE that this question is probably better placed elsewhere, although I would suggest the DSP stackexchange. Have a look here and see if you can get somewhere. If you want to start off with some self-study, I would recommend reading the following two paragraphs of the wikipedia page NPE mentioned:

Example: moving average filter, which may help you better understand the meaning of the coefficients; Frequency response of FIR filter, which will lead you in the right direction if you want to understand how convolving with this filter in the time domain alters the frequencies.