We have a module in python that implements a digital filter. The type is not relevant. The filter coefficients have been designed to implement a particular response, but there is additional code and wrappers around the filter all baked into a class implementation. I need to validate that the filter module/class is performing as expected.

In the real world, if I breadboarded an analog filter, I would program a signal generator to produce a range of sine waves, measure the response at each frequency and construct a frequency response. In the digital world, most people seem to use signal.freqz() -- which is an excellent tool -- but I want to confirm not the coefficients but the module as a whole. I'm imagining a tool that will drive our digital filter with signal content and measure the response. Possibly with sinusoids or step-functions.

I have indeed searched on this and most approaches assume knowledge of the coefficients, or attempt to derive the coefficients. But I want to validate the filter method as a whole.

Is there a tool to generate a frequency response empirically to validate a filter function?


2 Answers 2


If you are using a floating point implementation you can simply use a unit impulse as an test signal. The output will be the impulse response and you can take the Fourier Transform to get the frequency response.

Fixed point is different can of worms, since you need to manage headroom, signal to noise, clipping, limit cycles, etc.

  • $\begingroup$ Our systems are float64, so we are good there. I understand that theoretically a step-function response can fully describe a system and produce a frequency response, but I have concerns about the ability to generate a detailed response curve. It would make sense to use a swept-frequency approach to provide arbitrary levels of detail on the frequency response. We are looking for fine-grain differences that I don't think a step-function would provide. Perhaps I am wrong. I would imagine some tools exist for this. $\endgroup$
    – Hephaestus
    Sep 14, 2022 at 16:08
  • 1
    $\begingroup$ If this is a purely digital filter and all of the processing is done with double-precision float, there are no rounding or quantization error problems. Just bang it with a unit impulse function, let it ring until the output is at about $10^{-10}$ (stop at some power of 2 length), and FFT that impulse response. because you're double precision, there are no numerical issues with doing it that way and the frequency response will be exact. $\endgroup$ Sep 15, 2022 at 2:15
  • $\begingroup$ @Hephaestus: the unit impulse method (NOT step response) will be far superior in your case. Not only can you get arbitrary frequency resolution (simply by adjusting the FFT length) it will also give you the frequency resolution required to capture system completely within any level of accuracy required. $\endgroup$
    – Hilmar
    Sep 15, 2022 at 17:02

You can apply a chirp signal at the input with amplitude 1 and appropriate start/stop frequencies, and get the output of the filter.

The frequency response will be the FFT of the output. You can then plot the magnitude/phase of the FFT and check if it meets the requirements.


Your Answer

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

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