# Why the sum of filter coefficients of an FIR filter does not add to 1?

In MATLAB, I have generated an FIR low pass and high pass filter of order 16. The code is as follows:

filter1 = fir1(16,400/16000,'low') %%pass band-400Hz, Sampling frequency-16000Hz
filter2 = fir1(16,800/16000,'high') %%pass band-600Hz, Sampling frequency-16000Hz


The sum of coefficients of low pass filter adds to 1 whereas the sum of filter coefficients of high pass filter does not add to 1. Shouldn't the sum of filter coefficients add to 1?

• Could you add an explanation as to why you think the sum of the filter coefficients should equal 1? This might be the beginning of an answer. Commented Dec 7, 2022 at 12:13
• I asked your question of ChatGPT, and it came up with this answer over on Meta..
– Peter K.
Commented Dec 7, 2022 at 14:40
• The sum of the FIR coefficients always add the gain of the FIR filter at DC, 0 Hz. It doesn't matter if it's LPF or HPF or whatever. It's just that most LPFs have a passband gain that is close to 1 (or 0 dB) because the intent of the LPF filter is to pass the low-frequency content without scaling it. Commented Dec 7, 2022 at 17:37

## 3 Answers

I'm assuming your FIR filters are nonrecursive tapped-delay line FIR filters. For such filters the sum of a filter's coefficients will equal the filter's gain at zero Hz (DC). This property results from computing the zero-frequency bin of the DFT of a filter's impulse response (coefficients).

• And so it follows that the lowpass filter, which is designed to have approximately unity gain at DC, has coefficients that sum to 1, while the highpass filter, which has high attenuation at DC, has coefficients that sum to nearly zero. Commented Dec 7, 2022 at 14:13
• yeah, what they said. Commented Dec 7, 2022 at 17:38

A rule of thumb for a FIR filter that would:

• preserve the amplitude of low (resp. high) frequency signals
• reduce the amplitude of high (resp. low) frequency signals

could be memorized as follows.

The prototype of a low-frequency discrete signal is the constant one $$x_l=[\ldots,\,1,\,\,1,\,\,1,\,\,1,\,\ldots]$$. The prototype of a high-frequency discrete signal is the alternating one $$x_h=[\ldots,\,-1,\,\,1,\,\,-1,\,\,1,\,\ldots]$$.

Therefore, by convoluting a low-pass filter $$h_l$$ by $$x_l$$ one may expect that:

• $$\sum_k h_l[k] \simeq 1$$ (so that the constant input signal $$x_l$$ yields a filtered output almost identical)
• $$\pm1\sum_k (-1)^k h_l[k] \simeq 0$$ (or small enough).

Respectively, by convoluting a high-pass filter $$h_h$$ by $$x_h$$ one may expect that:

• $$\sum_k h_h[k] \simeq 0$$ (or small enough); the amplitude of the constant DC $$x_l$$ signal is shrunk
• $$\sum_k (-1)^k h_h[k] \simeq \pm1$$ alternatively (so that the odd/even output samples are similar to $$x_h$$, up to a 1-sample shift)

As one can read in the Mathworks help for command filter

https://www.mathworks.com/help/matlab/ref/filter.html?s_tid=srchtitle_filter_1

the sum of coefficients doesn't really have to be equal 1, or >1, or <1.

You choose such values for the filter to perform as required, in order to meet expected

• Gain
• Insertion Loss
• H(f) frequency response
• ..

With the Filter Designer App

one can edit coefficients a b, but the common practice is to fill out the design parameters and do not really spend much time on the particular values of the coefficients as long as the filter meets specs.