# Filter Order Rule of Thumb

Is there a rule of thumb for calculating the approximate filter order of a FIR/IIR based on passband vs sample rate? I seem to remember reading about it once in Undergrad. I'd think you could make a rough estimate like scaler * passband/stopband.

I have been working on implementing different FIR/IIR filters and would like some rough formula that says if one variable is changed, this is approximately how many more taps you would need to get similar performance.

• For FIR filters there's a formula given in this answer. – Matt L. Feb 15 '17 at 18:28

My favorite "Rule of thumb" for the order of a low-pass FIR filter is the "fred harris rule of thumb":

$$N=[f_s/delta(f)]*[atten(dB)/22]$$

where delta(f) is the transition band, in same units of $$f_s$$ $$f_s$$ is the sample rate of the filter atten(dB) is the target rejection in dB

For example if you have a transition band of 100 Hz in a system sampled at 1KHz, and your rejection requirement is 50 dB in the stop band then the order can be approximated by:

N= 1KHz/100Hz * 50/22 = 23 taps (rounding up)

Thank you fred harris!

Note another more detailed formula that takes into account passband ripple is Kaiser's formula thanks to James Kaiser from Bell Labs, which I included in my graphic below.

For most applications I have done, the fred harris approach has been just fine, as given a certain rejection, the resulting filters using traditional filter design algorithms such as Parks-McClellan and Remez have exceeded my passband ripple requirements upon meeting the rejection requirement. (What I usually do is estimate the order, design the filter with that order, inspect the result and increase or decrease order from there to fine tune). The results from the estimates are just that: estimates, and can vary widely depending on overall design parameters and not to be assumed to be an exact solution.

For those familiar with filter design using window approaches, review of the boxcar or rectangular window (which is simple truncation) reveals why it takes $$f_s/\Delta f$$ taps (which is the same as $$2\pi/\Delta\omega$$ if the units for normalized frequency are radians/sample as is often done) to complete the transition band. See the images below that help explain this.

The first image below shows the expected Sinc in frequency for a rectangular window in time, and then in discrete form, where it is an aliased Sinc function, with the key point that for N samples in time of the rectangular function, the frequency response will have its first null at f = 1/N (Where f is the normalized frequency with 1 being the sampling rate).

This next image shows the rectangular window approach to filter design (which I would never recommend but is informative). The first plot in the upper left hand corner shows the target frequency response for our filter as an ideal "brick wall" response. Please don't confuse that with the "boxcar window" (or "rectangular window") which is also a rectangular shape-- the window is in the time domain!

In order to realize such a filter, we would use the impulse response of the desired frequency response as the coefficients in our FIR filter (the coefficients of the filter are the impulse response---put an impulse in and out come all the coefficients!). The impulse response for a rectangular frequency (brickwall) response is the inverse FT which is a Sinc function, in the time domain, shown in the lower left hand corner as the "Required Impulse Response". A Sinc function extends to plus and minus infinity, so to actually realize such a filter we would need an infinitely long filter and it would have infinitely long delay. Obviously we can't do that, so we truncate the coefficients to something realizable. The longer the filter, the closer we approximate the ideal brickwall response, but also the longer the delay will be (and the more resources we would need in terms of the filter construction; more taps).

Truncating the impulse response in the time domain is mathematically identical to multiplying by a rectangular window in the time domain. (Note that the impulse response is also delayed by half the duration of the window in order for the system to be causal). Multiplying in the time domain is equivalent to convolution in the frequency domain. The frequency domain (FT) of the impulse response prior to truncation is our original desired brickwall frequency response. The frequency response for the rectangular window is a Sinc function in the frequency domain.

So when we truncate the desired impulse response (multiply in time by a rectangular window), we convolve the desired frequency response with a Sinc function, resulting in an approximation of our target frequency response as shown in the upper right-hand corner of the image below.

A key take-away for Sinc functions in general is the first null is 1/T where T is the duration of the rectangular function. For a sampled system, the first null would be at $$2\pi/N$$ where N represents the number of samples for the duration of the rectangular function. In the images a normalized radian frequency is used for the frequency axis- (if that confuses you just know the $$2 \pi$$ is the radian frequency for the sampling rate). So in the process of the convolution, the sharp brickwall transition spreads out and in this case goes to 0 (our $$\Delta \omega$$) over a frequency of $$2\pi/N$$! So here $$N = 2\pi/\Delta \omega$$ and of course the filter is poor with sidelobes etc. Note this: This transition from the Sinc function is the sharpest available for a given number of taps; it has the best resolution in frequency but the poorest dynamic range (rejection). Other window typologies (Blackman, Blackman-harris, Kaiser (my favorite), etc) will significantly improve dynamic range but always at the expense of the transition.

So from the above, we see the origin of the $$2\pi/\Delta\omega$$ that is used in the approximation formulas, and we also see why there is an additional multiplication factor increasing the number of taps above this for typical filter designs; the rectangular window would give us the best transition possible with N taps where $$N = 2\pi/\Delta\omega$$ but have very poor rejection. More taps are used to smooth the time transition further beyond the sharp transition of the rectangular window, providing greater rejection at the expense of transition bandwidth.

• Just to avoid confusion, the formula you call "Kaiser's formula" is actually the formula for Parks McClellan optimal filters (indeed found by Kaiser), but not for the Kaiser window method. The latter doesn't have two different $\delta$ values but only one. – Matt L. Feb 16 '17 at 17:08
• Indeed, good clarification Matt since there is a Kaiser window method. This formula is however referred to and known as "Kaiser's Formula" in the literature, just so readers don't think it was my own use of that term. engold.ui.ac.ir/~sabahi/Advanced%20digital%20communication/… – Dan Boschen Feb 16 '17 at 17:12
• Awesome! Looks like that came from page 48 in Fred Harris' book: "Multirate Signal Processing for Communication Systems"? – jeremy Feb 16 '17 at 19:08
• The rule of thumb or the pictures? The pictures are mine for a class I do. I don't have fred's book but I am a big fan and was introduced to his "rule of thumb" by him at a DSP World presentation he did back around 1996. (Note that he insists that his name be spelled with all lower case). – Dan Boschen Feb 16 '17 at 19:13
• @DanBoschen Is the formula for Parks McClellan also valid when designing bandpass FIR filters? If not, is there another "rule of thumb" that could be applied? – lR8n6i Aug 8 '17 at 19:22

The length of a FIR filter or order of an IIR filter is very roughly inversely proportional to the ratio of the transition-band's width (narrowest one, if many) to the sample rate, other things being somewhat equivalent, except for very short or very low order filters.

• dunno why someone downvoted. i fixed it back to zero. – robert bristow-johnson Feb 15 '17 at 19:28
• other things being somewhat equivalent ? – Ben Apr 27 at 14:41