# FIR filter usage / understanding FIR

Let us assume that I wouldd like to create a digital lowpass with 5 taps. I am not using a window function but just the impulse response from my Fourier integral.

I get the following coefficients: $h=[0.5\, 0.86 \,1 \,0.86\, 0.5]$.

What I don't understand: how does the filtering work? Assuming that I have a constant signal $x$ with '1' and I want to use the filter on that.

I applied the filter and what I get is

$$y=[0.5 \, 1.36\, 2.36\, 3.22\, 3.72\, 3.22\, 2.36\, 1.36\, 0.5 ]\,.$$ But now i am clueless how to draw this? The output is bigger then my input signal?

The good response by Laurent Duval provides a short overview of convolution and its properties and contains most of the information that you need. I think though that I see that you have some confusion about what is meant by filtering in general and how to apply a finite impulse response (FIR) filter in particular. I am attempting to explain some intuition behind FIR filtering here.

Something to keep in mind is that the length of an FIR filter should be shorter (preferably much shorter) than the signal that you wish to filter. This is because the result of a discrete convolution of two sequences is equal to the sum of the lengths of the sequences minus one, and part of this output is the transient response of the filter.

All filters have a transient response that applies to sudden changes in the input sequence (for example, a step function or discontinuity in the input). The beginning of a signal sequence looks like a step function to the filtering process (at least if you initialize your tap delay line with zeros as is typical). The end of the sequence has a similar transient response while zeros are being shifted in to replace the samples in the delay line.

The transient response occurs over the the first $N-1$ samples while the incoming signal is replacing the zeros in the delay line memory of the filter. This means that those first $N-1$ samples are not part of the steady state output of the filter. When we refer to the filtered signal, we are typically neglecting this transient response and are instead referring to the steady state output of the filter. This is often justified when the signal length is much greater than the filter length (the typical case), although not in your example where they are equal. If you use a filter of length $N$ and a signal of length $N$ as you have done, then the filtered output has length $2 N - 1$, and you have only $(2 N - 1) - 2 (N - 1) = 1$ sample that is not part of this (typically undesired) transient response. Most further processing will require more than $1$ sample to be effective, so this is probably not practical for you. In the typical case where the signal sequence length is much larger (say an order of magnitude or more), the steady state part of the output is also much longer than the transient part of the output.

Let's extend your example to illustrate this. If we were to apply your filter to a sequence of ones that contains $15$ samples instead of $5$, we would have an output sequence consisting of $15+5-1 = 19$ samples long. The first $4$ samples would be part of the transient and the last $4$ samples would be part of the transient (in fact, you can read this off of your $y$ output signal). If you were to drop these samples, you would see the steady state output which would be the value $3.72$ repeating $19-4-4 = 11$ times. Note that $3.72$ is the DC gain of your filter (the sum of the coefficients), so this is the expected outcome.

On the other hand, if we leave the first and last $N-1$ samples attached, then you would have $$y=[0.5 \, 1.36\, 2.36\, 3.22\, 3.72\, ...\, 3.72\, ...\, 3.72\, 3.22\, 2.36\, 1.36\, 0.5]$$ where you can easily see the transient parts at the beginning and end of the filtered sequence.

• Nice addition for the context – Laurent Duval Feb 7 '17 at 8:57
• Thank you ... now i have at least a rough understanding on what is happening. I took this example from my lecture of dsp and it said these is the impulse response of a low pass filter. So i obviuosly can't just put a steady signal in. Do you have a Signal and filter coefficient where i can actually calculate a lowpass? I'd like to draw it so i can see that the filter is really filtering high frquency signals ... but i can't come up with a good example myself. – Dennis Höhl Feb 7 '17 at 10:07
• I'm not sure I understand your question. You can apply a steady input signal to the impulse response of a filter. This is the typical case. For designing your own low pass filter, a first basic approach would be windowing a sinc function (search for window-based filter design or something like that). The Remez exchange algorithm (also called Parks-McClellan in the context of filter design) is a very popular "optimal" solution for filter design based on the minimax criteria. – hops Feb 7 '17 at 15:38

For a short overview of convolution you can check Convolution. For more details, the chapter Convolution by M. Hayes is interesting too, and especially the "Slide rule" version on page 15.

The convolution formula says $$(f\ast h)[n] = \sum_{m=-\infty}^{+\infty}h[m]f[n-m]$$ When the value of one argument is not defined, for instance with a negative index ($h[-1]$), one traditionally assumes that this value is $0$. Another interpretation is that filtering assumes $0$ values "outside" the known samples and coefficients.

The first output value will thus be: $$y[0] = x[0]h[0]$$ then $$y[1] = x[1]h[0] + x[0]h[1]$$then $$y[2] = x[2]h[0] + x[1]h[1] + x[0]h[2],$$ and so on.

For a filter with $L$ taps, and a signal of length $N$, you will obtain (at most) $L+N-1$ output samples. You probably have used a signal of five ones to get this result.

Additionally, your filter can be interpreted as a symmetric, positively weighted smoothing filter. The coefficient sums to a quantify greater than 1, so it also amplifies the DC component (or the signal's average).