Fast Track to Designing FIR Filters with Python
Thank you for your interest in the Fast Track to Designing FIR Filters with Python workshop! Below are the installation instructions as well as a Jupyter Notebook with the material that will be presented in the workshop.
Option 1: Easy path to Python: Install the Anaconda Individual Edition which will have all the tools we will be using: https://www.anaconda.
Option 2: Alternative manual path to Python: As a minimum install we will be using Python 3, Numpy, Matplotlib, and Scipy:
Install python: https://www.python.
From command window type:
pip install ipython
pip install numpy
pip install matplotlib
pip install scipy
(if you encounter any difficulty with installing the packages, see this page: https://packaging.
Being able to run Jupyter Notebooks is not necessary for the workshop but convenient as I am sharing the details of the workshop in the attached Jupyter Notebook for future reference. If you would like further basics on running the Notebook, please see this link:
https://www.datacamp.com/
Notebook: Fast Track FIR Filter Workshop.ipynb
Finite Impulse Response (FIR) filters are the more popular of the two main types of digital filter implementations used in DSP applications. In this workshop, we will go through best practice approaches for optimized FIR filter design and implementation using the free and open-source Python programming language. This will include the common techniques for going from filter requirements to practical implementation and demonstrate both creating FIR filter designs as well as evaluating filter frequency responses using the Python language and its signal processing library.
This workshop will include:
- Complete setup to get Python up and running for signal processing applications.
- Summary of the high-level approaches to FIR filter design – which are best and why?
- Fast track to using the signal processing library in Python for creating FIR designs.
- The complete design flow for FIR filters from specification through verification.
- Using Python for filter evaluation, including plotting magnitude and phase responses.
What this presentation is about and why it matters
This talk is a practical, fast-paced guide to designing linear‑phase finite impulse response (FIR) filters using Python. It walks from real filter specifications — passband ripple, stopband rejection and transition width — to estimating filter order, creating coefficients, and verifying the frequency response. The speaker focuses on approaches you will actually use in engineering: windowed designs (Kaiser), frequency‑sampling, and two optimized methods (Parks–McClellan/equiripple and least‑squares), and then demonstrates how to evaluate and apply filters to signals in Python.
Why it matters: FIR filters are everywhere in DSP — audio, communications, resampling, measurement, and sensors — because they can provide exact linear phase and stable, well‑behaved responses. Learning the practical design flow and the tradeoffs between methods will save time, avoid costly design mistakes, and let you choose the most appropriate algorithm for an application that requires a particular ripple, rejection, or computational constraint.
Who will benefit the most from this presentation
- Engineers and students who know basic DSP (sampling, spectra, convolution) and want practical filter design skills.
- Practitioners who need to design or prototype FIR filters quickly using Python and want to compare windowed vs. optimized designs.
- People integrating filters in software tools, real‑time systems, or multirate pipelines (resampling, anti‑aliasing) and who want clear rules of thumb for order estimation.
- Anyone who wants a working Jupyter notebook with examples and commands to adapt for real data (filter creation, freqz inspection, lfilter/filtfilt usage).
What you need to know
To get the most from the talk, be comfortable with these ideas and a few simple notations:
- Impulse response = coefficients: For an FIR filter the sequence of tap gains (coefficients) is exactly the impulse response. Its Fourier transform is the filter frequency response.
- Normalized frequency: The speaker uses frequencies normalized so the sampling rate is 1 and Nyquist is at $0.5$ (equivalently radian frequency runs $0$ to $\pi$). This is a common convention in many Python tools.
- Design specifications: Typical specs are passband edge $f_p$, stopband edge $f_s$, transition width $\Delta f = f_s - f_p$, passband ripple (dB) and stopband attenuation (dB). If you specify any two of {order, ripple, transition width} you determine the third.
- Order and taps: If filter order is $N$ then the number of taps is $N+1$. A very useful rule of thumb is that the required number of taps scales roughly as the inverse of the transition width: more narrow transitions need more taps. A simple estimator offered in the talk is Fred Harris’s rule of thumb: approximately $N \approx \dfrac{A/22}{\Delta f}$ where $A$ is the total attenuation in dB (useful for starting guesses).
- Window method vs. optimized methods: Windowing (sinc truncated and multiplied by a window like Kaiser) is simple, cheap and good for on‑the‑fly designs; optimized methods (Remez/equiripple and least‑squares) give better performance for fixed filters. Kaiser window has a beta parameter that trades main‑lobe width for sidelobe level; SciPy provides sig.kaiserord and sig.firwin for this flow.
- Tools and verification: Familiarity with SciPy (sig.firwin, sig.remez, sig.firls, sig.freqz), NumPy, Matplotlib and basic FFTs will let you reproduce the live demos: compute coefficients, plot magnitude/phase, and apply filters with sig.lfilter or zero‑phase sig.filtfilt.
Glossary (terms used in this talk)
- FIR (Finite Impulse Response): A filter whose impulse response has a finite duration. FIR filters can be designed with exactly linear phase when their coefficients are symmetric.
- Kaiser window: A parametric window function with adjustable sidelobe tradeoff, commonly used in FIR filter design and spectral analysis.
- DFT (Discrete Fourier Transform) / FFT (Fast Fourier Transform): The DFT maps time-domain samples into frequency-domain bins; the FFT is an efficient algorithm for computing the same transform.
- Passband ripple: The amount of variation in a filter’s gain across its passband, indicating how flat the desired frequency response is.
- Stopband attenuation: The degree to which a filter suppresses signals in its stopband, usually expressed in decibels.
- Impulse response: The output of a system to an impulse input; for an FIR filter, this is the coefficient sequence.
- DTFT (Discrete-Time Fourier Transform): The Fourier transform of a discrete-time sequence, yielding a continuous frequency-domain representation.
- Linear phase: A phase response that varies linearly with frequency, producing constant group delay and preserving waveform shape.
Toolbox (mentioned in this talk)
- NumPy: A foundational Python library for array computing and numerical operations.
- SciPy: A Python library that provides scientific computing algorithms built on NumPy.
- Matplotlib: A Python plotting library used for creating static, animated, and interactive visualizations.
- Jupyter Notebook: An interactive notebook environment for combining code, text, and visualizations in a single document.
- sig.firwin: A SciPy signal-processing function for designing FIR filters, commonly using window-based methods.
- sig.remez: A SciPy signal-processing function for equiripple FIR filter design using the Parks–McClellan method.
Final thoughts
What is the main reason the speaker prefers linear-phase FIR filters for many applications?
At 27:50 It is said: "In LS frequency Response - Decreasing rolloff is good for Multi rate filters, as they can all alias in"
Can anyone throw more light on, how this aliasing between stop band ripples help in the design of multirate filters ?
This is further detailed on this post I wrote on stackexchange: https://dsp.stackexchange.com/questions/52834/the-condition-in-order-to-not-lose-information-after-upsampling-and-downsampling/52860#52860
If you make the poor choice of using a filter with an equal level stop-band, with high decimation factors these will all accumulate as they alias in. If the stop-band is rolling off then only the first and dominant ones will contribute to in band noise from the aliasing.
Decimation (by selecting every Dth sample) results in higher frequency bands in the original wider frequency spectrum that will alias in to the final output spectrum. This is identical to the process of sampling an analog signal (which is decimating an infinitely sampled signal basically) and why we need anti-alias filtering prior to the sampling. With decimation similarly we need anti-alias filtering prior to decimation and for this if done with an FIR filter it is preferred to use a filter with a stopband that rolls off.
Great Workshop!
10:58:35 From Dan Boschen : hello! 11:27:27 From Fred Harris : ofdm is the best example of thefrequency sampled data filter because all sampled tones in the ofdm signal match the kernels of the the DFT. 11:34:07 From Stephane Boucher : https://www.dsprelated.com/new2/course_registration_dsp_wireless.php 11:55:54 From Dave Comer : I'm sorry I missed your comment details on where you said the Juypter notebook(s) can be downloaded? My apologies. 11:56:26 From Dave Comer : Thank you. 11:56:37 From Stephane Boucher : It is actually currently available here: https://www.dsprelated.com/new2/course_registration_dsp_wireless.php 11:56:49 From Stephane Boucher : Simply click on the 'Description tab' 11:57:17 From Michael Kirkhart : Is this the link to the ipython notebook? : https://s3.amazonaws.com/embeddedrelated/user/1/fast%20track%20fir%20filter%20workshop_89335.ipynb 11:58:29 From Stephane Boucher : Yes, that should be it 12:07:27 From mnapier : Just an observation. The multiband filters are handy for doing resampling. In that case its not multiple pass bands but multiple stop bands. Each stop band where there is an image that needs to be rejected. In between those are don't care regions. The multiple stop bands allow the FIR zeros to be concentrated in area that matter and so reduce the order required. 12:21:35 From gs : Awesome presentation! Newbie question on implementation: I am streaming 500sps data into python, circ-buffering/notch-filtering in chunks of N*500 in np, scipy windowing/fft, and graphing in real-ish time. Have learned a lot so far, and would now like to filter data stream on sample-by-sample basis instead of chunks. Any pointers on how to do this in python? Also, any comments on practical/custom notch filtering (to remove nasty 60 cycle in this case)? Thx, Gil 12:28:43 From Radu Pralea : For aligning the input and output (filtered) signal, without anti-causally passing it twice through the filter (modifying the response), we can always simply discard first N/2 output samples (the group delay), and flush the filter at the end (feed it an additional N/2 zero-samples at the end). 12:29:25 From David Robinson : The trick is the closer to DC, the more risk to have unstability with qusntization 12:29:52 From David Robinson : See the presentation of fred harris last Monday on this topic 12:30:34 From gs : Yes, Fred's talks were incredible. thx 12:31:00 From Rob K. : thanks, dan. great talk 12:31:18 From Mike Swanson : thank you! 12:31:58 From Terrence Lawrence : great talk and demo

Hi Dan, great workshop indeed.
I've wondered if it's possible to get the jupyter notebooks that you used during presentation?
Thanks!