Filter Design: Windows, Bilinear Transform & Prototypes

Filter design turns passband, stopband, phase, latency, and numerical constraints into coefficients that still meet the requirement after implementation. This entry connects FIR window and equiripple methods with analogue-prototype IIR design, bilinear prewarping, second-order sections, and verification against the original mask.

builds onFilter Stability & the Unit Circle

Filter design begins with an inequality, not with “use Butterworth” or “choose 101 taps.” The required passband edge and ripple, stopband edge and attenuation, sampling rate, phase distortion, latency, dynamic range, and deployment arithmetic define a feasible set. A design method chooses one member; implementation and measurement decide whether that member survives reality.

The filter's order is therefore an output of the specification. If the transition width tends to zero while attenuation stays finite, required order tends to infinity. A sharp edge always costs delay, arithmetic, sensitivity, or all three.

Write the mask in physical units #

For a low-pass example at fs=48f_s=48 kHz:

Requirement Value
passband edge fpf_p 5 kHz
passband loss at most 0.2 dB
stopband edge fs′f_s' 7 kHz
stopband attenuation at least 70 dB
maximum group-delay variation in passband 0.1 ms
arithmetic float32, streaming

Convert decibel limits to linear bounds before design:

1−δp≤∣H(ejω)∣≤1+δp,∣H(ejω)∣≤δs.1-\delta_p\le |H(e^{j\omega})|\le1+\delta_p, \qquad |H(e^{j\omega})|\le\delta_s.

For a 70 dB stopband, δs=10−70/20≈3.16×10−4\delta_s=10^{-70/20}\approx3.16\times10^{-4}. Passband ripple stated as peak-to-peak dB needs an explicit convention; silently treating it as one-sided loss changes weights and order.

FIR design: choose the impulse response directly #

An ideal low-pass frequency response has a sinc impulse response of infinite length. Truncating it with a finite window produces a realizable FIR:

h[n]=hideal[n]w[n].h[n]=h_{ideal}[n]w[n].

This is the window method. Its strengths are predictability, simple control of sidelobes through the window, and exact linear phase when coefficients are symmetric. Its weakness is indirect optimization: passband ripple, stopband attenuation, and transition width follow the chosen window and length rather than being independently minimized.

For a length-LL symmetric FIR,

h[n]=h[L−1−n],h[n]=h[L-1-n],

and group delay is (L−1)/2(L-1)/2 samples away from zeros of the response. At 48 kHz, 241 taps impose 2.5 ms delay. That may be harmless in offline measurement and unacceptable in a feedback loop.

Equiripple design spends error where the mask permits it #

The Parks–McClellan/Remez method solves a minimax approximation: choose a linear-phase FIR whose maximum weighted error over specified bands is as small as possible. At optimum, error alternates between nearly equal extrema. Band weights trade passband ripple against stopband leakage.

Equiripple typically needs fewer taps than a generic window for the same piecewise-constant mask. It does not optimize every goal: time-domain ringing, coefficient sparsity, minimum phase, and arbitrary perceptual cost require different formulations.

FIR choices:

Method Use when Verify especially
windowed sinc a robust conventional shape is sufficient achieved edges and attenuation
equiripple order matters and bands have hard max-error bounds extremal grid, narrow bands, quantized ripple
least squares average squared error matters more than worst case local peaks that the objective tolerates
frequency sampling exact samples or unusual periodic shapes matter response between specified samples

IIR design: map an analogue prototype #

Classical low-pass prototypes encode different magnitude compromises:

Prototype Passband Stopband Consequence
Butterworth maximally flat monotonic moderate transition, smooth amplitude
Chebyshev I equal ripple monotonic sharper edge by spending passband ripple
Chebyshev II monotonic equal ripple sharper edge by spending stopband ripple
Elliptic equal ripple equal ripple lowest order for magnitude limits, most sensitive phase/coefficients
Bessel/Thomson optimized delay flatness gentle roll-off preserves waveform shape, weak selectivity

An analogue prototype Ha(s)H_a(s) must be mapped to discrete time. The bilinear transform

s=2fs(1−z−1)1+z−1s=\frac{2f_s(1-z^{-1})}{1+z^{-1}}

maps the entire stable left half of the ss-plane inside the unit circle, so stable analogue poles remain stable. It also warps frequency:

Ω=2fstan⁡(ω2).\Omega=2f_s\tan\left(\frac{\omega}{2}\right).

To place a digital critical frequency exactly, prewarp it into the analogue prototype before mapping. Multiple edges cannot all be preserved by one global linear scale, which is why band transformations and library order solvers matter.

Impulse invariance is another mapping: sample the analogue impulse response. It preserves pole exponentials but aliases the analogue frequency response, so it is suitable only when high-frequency analogue energy is negligible relative to sampling.

Implement IIR filters as second-order sections #

An $N$th-order transfer function stored as polynomial coefficient arrays is numerically fragile. Root-to-polynomial conversion amplifies coefficient error; a high-order narrowband filter can look correct in double precision and move poles enough to fail in float32.

Factor the filter into biquads:

H(z)=g∏m=1Mb0m+b1mz−1+b2mz−21+a1mz−1+a2mz−2.H(z)=g\prod_{m=1}^{M} \frac{b_{0m}+b_{1m}z^{-1}+b_{2m}z^{-2}} {1+a_{1m}z^{-1}+a_{2m}z^{-2}}.

SciPy explicitly recommends second-order-section output for general filtering and warns that transfer-function form becomes numerically sensitive even for modest order. But SOS is not automatically safe: section order and gain distribution determine internal peak states. Pair poles and zeros sensibly, scale sections for expected signals, and test overflow and state transients in the actual arithmetic.

For fixed point, coefficient word length, accumulator width, rounding, saturation, and limit cycles are part of the design. Quantize coefficients before the final pole/zero and response checks.

Verification is against the mask, not the plot #

Evaluate the implemented coefficients on a dense grid that includes every edge and any narrow feature. Then compute explicit margins:

Mp=Aallowed,p−Ameasured,p,Ms=Ameasured,s−Arequired,s,M_p=A_{allowed,p}-A_{measured,p}, \qquad M_s=A_{measured,s}-A_{required,s},

using a consistent sign convention. Report the worst frequency, not only “meets 70 dB.” A coarse grid can step over a narrow ripple maximum.

Also verify:

  • all IIR poles lie inside the unit circle after coefficient quantization;
  • phase or group delay over the signal band meets the waveform requirement;
  • impulse and step responses decay as expected and reveal ringing;
  • maximum internal state is safe for full-scale, impulse, step, multitone, and adversarial inputs;
  • streaming state across blocks matches one-shot filtering;
  • startup, reset, and coefficient-change transients are acceptable;
  • forward-backward offline filtering is not accidentally deployed where causality matters.

A practical decision sequence #

  1. State the mask, signal units, fsf_s, acceptable delay, and arithmetic.
  2. If exact linear phase is required, design a symmetric FIR and see whether its delay/order is affordable.
  3. If low order and latency dominate, select an IIR prototype by the permitted ripple and delay distortion.
  4. Let an order-selection routine solve the minimum order, then add implementation margin.
  5. Request SOS for IIR; retain full-precision design coefficients as the reference.
  6. Quantize into the deployed representation and rerun every response/stability test.
  7. Exercise the filter in the complete chain: anti-aliasing, resampling, scaling, block boundaries, and saturation can invalidate an isolated design.
  8. Save the original specification beside coefficients so a later sampling-rate or signal-band change cannot silently reuse them.

The design is finished only when the deployed structure meets the physical mask with measured margin. A named prototype and a convincing response screenshot are intermediate artifacts.

Sources

  1. docsSciPy: butter
  2. docsSciPy Signal Processing: Filter Design
  3. paperChebyshev Approximation for Nonrecursive Digital Filters with Linear Phase
  4. bookFundamentals of Information Processes 1: Collection, Transmission and Processing of Informationpdfnotes

Searches titles, aliases, headings, summaries, and full text.↑↓ move ↵ open esc close