Connexions

You are here: Home » Content » Parks-McClellan FIR Filter Design
Content Actions
Lenses

What is a lens?

Lenses

A lens is a custom view of Connexions content. You can think of it as a fancy kind of list that will let you see Connexions through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to Connexions materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual Connexions member, a community, or a respected organization.

This content is ...
Affiliated with (?)
This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
  • This module is included inLens: Rice University OpenCourseWare
    By: OpenCourseWare ConsortiumAs a part of collection:"Digital Filter Design"

    Click the "Rice University OCW" link to see all content affiliated with them.

    Rice University OCW
Tags

(?)

These tags come from the endorsement, affiliation, and other lenses that include this content.

Parks-McClellan FIR Filter Design

Module by: Douglas L. Jones

The approximation tolerances for a filter are very often given in terms of the maximum, or worst-case, deviation within frequency bands. For example, we might wish a lowpass filter in a (16-bit) CD player to have no more than 12 1 2 -bit deviation in the pass and stop bands.
Hω=1-1217|Hω|1+1217if|ω| ω p 1217|Hω|if ω s |ω|π H ω 1 1 2 17 H ω 1 1 2 17 ω ω p 1 2 17 H ω ω s ω
The Parks-McClellan filter design method efficiently designs linear-phase FIR filters that are optimal in terms of worst-case (minimax) error. Typically, we would like to have the shortest-length filter achieving these specifications. Figure Figure 1 illustrates the amplitude frequency response of such a filter.
fig1.png
Figure 1: The black boxes on the left and right are the passbands, the black boxes in the middle represent the stop band, and the space between the boxes are the transition bands. Note that overshoots may be allowed in the transition bands.
Problem 1
Must there be a transition band?
[ Click for Solution 1 ]
Solution 1
Yes, when the desired response is discontinuous. Since the frequency response of a finite-length filter must be continuous, without a transition band the worst-case error could be no less than half the discontinuity.
[ Hide Solution 1 ]

Formal Statement of the L-∞ (Minimax) Design Problem

For a given filter length (MM) and type (odd length, symmetric, linear phase, for example), and a relative error weighting function Wω W ω , find the filter coefficients minimizing the maximum error argminhargmaxωF|Eω|=argminhEω h ω F E ω h E ω where Eω=Wω H d ω-Hω E ω W ω H d ω H ω and FF is a compact subset of ω0π ω 0 (i.e., all ωω in the passbands and stop bands).
Note: Typically, we would often rather specify Eωδ E ω δ and minimize over MM and hh; however, the design techniques minimize δδ for a given MM. One then repeats the design procedure for different MM until the minimum MM satisfying the requirements is found.
We will discuss in detail the design only of odd-length symmetric linear-phase FIR filters. Even-length and anti-symmetric linear phase FIR filters are essentially the same except for a slightly different implicit weighting function. For arbitrary phase, exactly optimal design procedures have only recently been developed (1990).

Outline of L-∞ Filter Design

The Parks-McClellan method adopts an indirect method for finding the minimax-optimal filter coefficients.
  1. Using results from Approximation Theory, simple conditions for determining whether a given filter is L L (minimax) optimal are found.
  2. An iterative method for finding a filter which satisfies these conditions (and which is thus optimal) is developed.
That is, the L L filter design problem is actually solved indirectly.

Conditions for L-∞ Optimality of a Linear-phase FIR Filter

All conditions are based on Chebyshev's "Alternation Theorem," a mathematical fact from polynomial approximation theory.

Alternation Theorem

Let FF be a compact subset on the real axis xx, and let Px P x be and LLth-order polynomial Px=k=0L a k xk P x k L 0 a k x k Also, let Dx D x be a desired function of xx that is continuous on FF, and Wx W x a positive, continuous weighting function on FF. Define the error Ex E x on FF as Ex=WxDx-Px E x W x D x P x and Ex=argmaxxF|Ex| E x x F E x A necessary and sufficient condition that Px P x is the unique LLth-order polynomial minimizing Ex E x is that Ex E x exhibits at least L+2 L 2 "alternations;" that is, there must exist at least L+2 L 2 values of xx, x k F x k F , k=01L+1 k 0 1 L 1 , such that x 0 < x 1 << x L + 2 x 0 x 1 x L + 2 and such that E x k =-E x k + 1 =±E E x k E x k + 1 ± E
Problem 2
What does this have to do with linear-phase filter design?
[ Click for Solution 2 ]
Solution 2
It's the same problem! To show that, consider an odd-length, symmetric linear phase filter.
Hω=n=0M-1hn-ωn=-ωM-12hM-12+2n=1LhM-12-ncosωn H ω n M 1 0 h n ω n ω M 1 2 h M 1 2 2 n L 1 h M 1 2 n ω n (1)
Aω=hL+2n=1LhL-ncosωn A ω h L 2 n L 1 h L n ω n (2)
Where LM-12 L M 1 2 .
Using trigonometric identities (such as cosnα=2cosn-1αcosα-cosn-2α n α 2 n 1 α α n 2 α ), we can rewrite Aω A ω as Aω=hL+2n=1LhL-ncosωn=k=0L α k coskω A ω h L 2 n L 1 h L n ω n k L 0 α k ω k where the α k α k are related to the hn h n by a linear transformation. Now, let x=cosω x ω . This is a one-to-one mapping from x-11 x -1 1 onto ω0π ω 0 . Thus Aω A ω is an LLth-order polynomial in x=cosω x ω !
implication: The alternation theorem holds for the L L filter design problem, too!
Therefore, to determine whether or not a length-MM, odd-length, symmetric linear-phase filter is optimal in an L L sense, simply count the alternations in Eω=WωAdω-Aω Eω Wω Ad ω Aω in the pass and stop bands. If there are L+2=M+32 L2 M3 2 or more alternations, hnhn, 0nM-10n M1 is the optimal filter!
[ Hide Solution 2 ]

Optimality Conditions for Even-length Symmetric Linear-phase Filters

For M M even, Aω=n=0LhL-ncosωn+12 A ω n 0 L h L n ω n 1 2 where L=M2-1 L M 2 1 Using the trigonometric identity cosα+β=cosα-β+2cosαcosβ α β α β 2 α β to pull out the ω2 ω 2 term and then using the other trig identities, it can be shown that Aω A ω can be written as Aω=cosω2k=0L α k coskω A ω ω 2 k 0 L α k ω k Again, this is a polynomial in x=cosω x ω , except for a weighting function out in front.
Eω=Wω A d ω-Aω=Wω A d ω-cosω2Pω=Wωcosω2 A d ωcosω2-Pω E ω W ω A d ω A ω W ω A d ω ω 2 P ω W ω ω 2 A d ω ω 2 P ω (3)
which implies
Ex= W ' x A d ' x-Px E x W ' x A d ' x P x (4)
where W ' x=Wcosx-1cos12cosx-1 W ' x W x 1 2 x and A d ' x= A d cosx-1cos12cosx-1 A d ' x A d x 1 2 x Again, this is a polynomial approximation problem, so the alternation theorem holds. If Eω E ω has at least L+2=M2+1 L 2 M 2 1 alternations, the even-length symmetric filter is optimal in an L L sense.
The prototypical filter design problem: W=1if|ω| ω p δ s δ p if| ω s ||ω| W 1 ω ω p δ s δ p ω s ω See Figure 2.
fig2.png
Figure 2

L-∞ Optimal Lowpass Filter Design Lemma

  1. The maximum possible number of alternations for a lowpass filter is L+3 L 3 : The proof is that the extrema of a polynomial occur only where the derivative is zero: xPx=0 x P x 0 . Since Px P x is an ( L - 1 ) ( L - 1 ) th-order polynomial, it can have at most L - 1 L - 1 zeros. However, the mapping x=cosω x ω implies that ωAω=0 ω A ω 0 at ω=0 ω 0 and ω=π ω , for two more possible alternation points. Finally, the band edges can also be alternations, for a total of L-1+2+2=L+3 L 1 2 2 L 3 possible alternations.
  2. There must be an alternation at either ω=0 ω 0 or ω=π ω .
  3. Alternations must occur at ω p ω p and ω s ω s . See Figure 2.
  4. The filter must be equiripple except at possibly ω=0 ω 0 or ω=π ω . Again see Figure 2.
Note: The alternation theorem doesn't directly suggest a method for computing the optimal filter. It simply tells us how to recognize that a filter is optimal, or isn't optimal. What we need is an intelligent way of guessing the optimal filter coefficients.
In matrix form, these L+2 L 2 simultaneous equations become 1cos ω 0 cos2 ω 0 ...cosL ω 0 1W ω 0 1cos ω 1 cos2 ω 1 ...cosL ω 1 -1W ω 1 ......1cos ω L + 1 cos2 ω L + 1 ...cosL ω L + 1 ±1W ω L + 1 hLhL-1h1h0δ= A d ω 0 A d ω 1 A d ω L + 1 1 ω 0 2 ω 0 ... L ω 0 1 W ω 0 1 ω 1 2 ω 1 ... L ω 1 -1 W ω 1 ... ... 1 ω L + 1 2 ω L + 1 ... L ω L + 1 ± 1 W ω L + 1 h L h L 1 h 1 h 0 δ A d ω 0 A d ω 1 A d ω L + 1 or Whδ=Ad W h δ A d So, for the given set of L+2 L 2 extremal frequencies, we can solve for h h and δ δ via hδT=W-1Ad h δ W A d . Using the FFT, we can compute Aω A ω of hn h n , on a dense set of frequencies. If the old ω k ω k are, in fact the extremal locations of Aω A ω , then the alternation theorem is satisfied and hn h n is optimal. If not, repeat the process with the new extremal locations.

Computational Cost

OL3 O L 3 for the matrix inverse and Nlog2N N 2 N for the FFT ( N32L N 32 L , typically), per iteration!
This method is expensive computationally due to the matrix inverse.
A more efficient variation of this method was developed by Parks and McClellan (1972), and is based on the Remez exchange algorithm. To understand the Remez exchange algorithm, we first need to understand Lagrange Interpoloation.
Now Aω A ω is an L Lth-order polynomial in x=cosω x ω , so Lagrange interpolation can be used to exactly compute Aω A ω from L+1 L 1 samples of A ω k A ω k , k=012...L k 0 1 2 ... L .
Thus, given a set of extremal frequencies and knowing δ δ, samples of the amplitude response Aω A ω can be computed directly from the
A ω k =-1k+1W ω k δ+ A d ω k A ω k 1 k 1 W ω k δ A d ω k (5)
without solving for the filter coefficients!
This leads to computational savings!
Note that Equation 5 is a set of L+2 L 2 simultaneous equations, which can be solved for δ δ to obtain (Rabiner, 1975)
δ=k=0L+1 γ k A d ω k k=0L+1-1k+1 γ k W ω k δ k 0 L 1 γ k A d ω k k 0 L 1 1 k 1 γ k W ω k (6)
where γ k =i=0ikL+11cos ω k -cos ω i γ k i i k 0 L 1 1 ω k ω i The result is the Parks-McClellan FIR filter design method, which is simply an application of the Remez exchange algorithm to the filter design problem. See Figure 3.
fig3.png
Figure 3: The initial guess of extremal frequencies is usually equally spaced in the band. Computing δ δ costs OL2 O L 2 . Using Lagrange interpolation costs O16LLO16L2 O 16 L L O 16 L 2 . Computing hn h n costs OL3 O L 3 , but it is only done once!
The cost per iteration is O16L2 O 16 L 2 , as opposed to OL3 O L 3 ; much more efficient for large L L. Can also interpolate to DFT sample frequencies, take inverse FFT to get corresponding filter coefficients, and zeropad and take longer FFT to efficiently interpolate.

Comments, questions, feedback, criticisms?

Send feedback