I've implemented 2 filters in Python I would like to know if they look OK or not.. I've implemented an lowpass FIR Hann Filter and an lowpass IIR Chebyshev type 1 filter. My plots look like the following: Time amplitudeTime amplitude and frequency spectrum: enter image description here Hann Window: enter image description here

Cheby 1: enter image description here Is there something that I did wrong, that I should improve??

  • $\begingroup$ Please show the frequency and phase response for the two filters using scipy.signal.freqz, that is what you should be comparing between the two and not spectrums of your actual data. $\endgroup$ Apr 19, 2020 at 16:33
  • $\begingroup$ @DanBoschen edited the question, please see the last 2 plots $\endgroup$
    – bicanul123
    Apr 19, 2020 at 16:37
  • $\begingroup$ Plot with the y axis as dB using 20*np.log10(abs(h)), and better if you could paste just the plots and not your whole screen. Use Ctrl-Alt-PrintScreen once the window is selected to just copy that to your buffer $\endgroup$ Apr 19, 2020 at 16:44
  • $\begingroup$ Sorry, I'll post just the plots $\endgroup$
    – bicanul123
    Apr 19, 2020 at 17:00
  • $\begingroup$ @DanBoschen posted what you've asked for $\endgroup$
    – bicanul123
    Apr 19, 2020 at 17:10

1 Answer 1


After roughly observing the output spectrum, I found something strange.

First, I noticed that you're coping with audio(voice) signals. Because telephones are made to work in the ranges 300 Hz to 3400 Hz [1], it seems that your IIR filter has filtered out the frequency components higher than about 1kHz. Is that what you intended to do?

Second, I noticed that your FIR filter is a kind of LPF but I cannot do any further inference, because frequency/phase responses of impulse signal have not given. (you can create an impulse signal and then plot the spectrum as you have done.)

When it comes to the design of a filter, the spec of the filter should be discussed.

First, you need to assign the cut-off frequency (or which part of the signal do you want to filtered?). From the output spectrum of your signals, I suspect that you use two different cut-off frequencies when comparing IIR/FIR filter. If you just wanna filtered out high frequency noise, you need firstly decide the range. Maybe you can refer to [2].

Here are some frequently discussed basic spec from my experience.

  1. Is application real-time or not? This can determine whether you can use the so-called filtfilt technique. (Zero delay at expense of causality. (you need to recorded all signal and))

  2. Is General linear phase (GLP) required? If so, IIR in filtfilt or GLP FIR Filter are your choices.

  3. Usually, IIR can obtain better stop band attenuation with lower orders. However, the delay might vary from different frequencies to other frequencies. For extremely bad example, the input is 'do re mi' but the output becomes 're mi do'.

There are some more info like [3], hope it can help.

[1] https://en.wikipedia.org/wiki/Voice_frequency

[2] What is the bandwidth of human speech?

[3] https://www.gaussianwaves.com/2017/02/choosing-a-filter-fir-or-iir-understanding-the-design-perspective/

  • 1
    $\begingroup$ Thanks for the reply! I don't have any experience regarding this area, it is just for learning purpose..I need to Design the filters with the required specifications and compare the results. There is a FIR filter to be designed with the window method and an IIR filter, I'm asking to see if they are correctly implemented... $\endgroup$
    – bicanul123
    Apr 19, 2020 at 16:28
  • 1
    $\begingroup$ This somehow depends on the definition of 'correctly implemented'. The code works and the filters are implemented. So, they are somehow correctly implemented. You've done the first step. Good! But in fact, the design of filters is a kind of art and there is no absolute correct answer. It depends! We need to deal with some trade-off. One role of a signal algorithm engineer is to explain to your stackholder why you design the filter in this way. What's the pros and cons. $\endgroup$ Apr 19, 2020 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.