S7 · Lesson 23 · Optimal equiripple FIR design
The minimax criterion, weighted error, the alternation theorem, the Parks–McClellan algorithm and how long an optimal filter must be
A windowed design spends its ripple unevenly: the error is largest near the band edges and shrinks away from them, so most of the passband and stopband are better than they need to be, and that slack is paid for in taps. The best possible filter of a given length spreads its error evenly, touching the allowed limit again and again across every band. Parks and McClellan turned that idea into an algorithm in 1972, and it remains the standard way to design FIR filters: given band edges, ripple limits and a length, it returns the filter whose largest weighted error is as small as it can be.
- The filter order M needed to meet a lowpass specification against its transition width Δω, for a Kaiser window design (dashed) and for an optimal equiripple design (solid), from each method's length formula.
- The stopband needs A dB of attenuation; the passband ripple is a ratio K times the stopband's δ.
- The equiripple design is always shorter, and the saving is largest when the passband can be looser than the stopband, which the window method can't exploit.
Predict
A lowpass needs δ₁ = 0.01 in its passband, δ₂ = 0.001 in its stopband and a 0.2π transition. Kaiser's window needs M = 37. Roughly what order does an equiripple design need?
Kaiser's estimate for equiripple filters gives = 37/1.460 = 25.3, so 26; in Oppenheim and Schafer's example, M = 26 just misses and M = 27 meets the specification. The window design must hold the tighter δ = 0.001 in both bands, while the equiripple design uses the looser passband allowance to save ten taps.
Name it
The minimax criterion
For a Type I filter with , L = M/2, choose the coefficients to minimize the largest weighted error
over the passband and stopband (the transition band is "don't care"). With W = 1/K in the passband and 1 in the stopband, , the optimal filter has ripples exactly and .
The alternation theorem
is the unique best approximation if and only if E(ω) attains its maximum magnitude, with alternating signs, at at least L + 2 frequencies in the bands. A lowpass optimum has L + 2 or L + 3 such extremal frequencies (the latter an "extraripple" filter), and the band edges and are always among them.
The Parks–McClellan algorithm
The Remez exchange: guess L + 2 extremal frequencies, solve for the polynomial that alternates with equal error δ there, find where the actual error peaks, move the guesses to those peaks, and repeat until they stop moving. It converges in a few iterations to the optimum.
How long it must be
against the Kaiser window's with A set by the smaller δ. Passband ripple in dB relates to δ₁ by .
Worked example
Estimate the order for = 0.4π, = 0.6π, δ₁ = 0.01, δ₂ = 0.001, and compare with a Kaiser window.
Show the solution
- Equiripple order. so M ≈ 26.
- Kaiser order. Kaiser must meet 0.001 everywhere, so A = 60: so 37.
- Compare. The equiripple filter needs about 10 fewer multiplications per sample.
- Weight. With weight K = 10, the stopband error counts ten times as much as the passband's.
Answer about M = 26 for equiripple, against M = 37 for a Kaiser window.
Worked example
A specification gives 0.1 dB of passband ripple. What δ₁ is that?
Show the solution
- Ripple as a ratio.
- Solve for δ₁.
- Weight. Paired with 60 dB in the stopband (δ₂ = 0.001), the weight is K = 5.76.
Answer δ₁ = 0.00576.
Worked example
A filter may ripple by 0.87 dB in its passband (δ₁ = 0.05) but needs 80 dB of rejection (δ₂ = 10⁻⁴), with a 0.05π transition. Compare equiripple and Kaiser lengths.
Show the solution
- Product of the ripples. , so
- Equiripple.
- Kaiser. Kaiser has to use the smaller δ in both bands:
- Compare. Because the window method can't loosen the passband, the optimal design needs barely half the taps when the two tolerances differ this much.
Answer about 110 for equiripple against 201 for Kaiser.
Check
An equiripple lowpass needs δ₁ = 0.05, δ₂ = 0.001 and a 0.2π transition. What order does Kaiser's estimate give?
Check
For the same specification, how many more orders does a Kaiser window design need (both before rounding)?
Check
A passband may ripple by 0.1 dB peak to peak. What's δ₁?
Check
An optimal Type I lowpass has order M = 36. At least how many alternation frequencies does its error have?
Check
A design needs δ₁ = 0.01 and δ₂ = 0.001. What passband-to-stopband ripple ratio K does the weighting use?
Check
What stopband attenuation does δ₂ = 0.001 mean?
Check
A lowpass may ripple 0.5 dB peak to peak in its passband, must reject 50 dB, and has a 0.1π transition.
(a)
What is δ₁?
(b)
What equiripple order does Kaiser's estimate give?
Check
A lowpass has ripples a (passband) and b (stopband, b < a) and transition width d rad.
Step 1
What equiripple order does the estimate give?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
What attenuation must a Kaiser window meet?
Step 3
What order does the Kaiser window need?
Explain why
Why is an equiripple filter shorter than a windowed filter that meets the same specification?
A windowed design's error is largest next to the band edges and dies away across each band, so far from the edges it's much smaller than the specification allows. Those unused margins are wasted capacity: they represent degrees of freedom in the coefficients spent on being better than necessary. The optimal design spreads the error evenly, pressing against the limit at many frequencies in each band, so every coefficient is working to meet the specification. It can also give different bands different tolerances through the weighting, while a window forces the same ripple in both. For the same specification it therefore needs fewer coefficients, typically 20 to 30% fewer.
Practice
Keep practicing
10 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.