Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 52

Parks-McClellan Algorithm for FIR Filter Design

Recommended resources

Hello! Welcome to your next lesson on designing digital filters.

In our last two lessons, we explored the windowing and frequency sampling methods for FIR filter design. While both are intuitive, they represent a compromise. The window method trades main-lobe width for side-lobe height, and the frequency sampling method provides perfect accuracy only at specific frequency points. Neither is guaranteed to be the best possible filter for a given number of coefficients.

This leads us to a fundamental question: What does it mean for a filter to be "optimal," and how do we design one? Today, we will answer that question. Our learning outcome is to describe the principles of the Parks-McClellan algorithm for designing optimal equiripple FIR filters.

This powerful algorithm approaches filter design as an optimization problem. It's rooted in deep mathematical principles from polynomial approximation theory, and it produces filters that are optimal in a very specific and useful sense: they minimize the maximum error across the frequency bands of interest.

This lesson will cover:

  • The "minimax" error criterion that defines an optimal FIR filter.
  • The Alternation Theorem, the mathematical cornerstone of the algorithm.
  • The iterative steps of the Parks-McClellan algorithm, which is an implementation of the Remez exchange algorithm.
  • Practical considerations, such as using a weighting function to control performance.

1. The Minimax Criterion and Equiripple Filters

The goal of the Parks-McClellan algorithm is to design a filter whose frequency response is the best possible approximation to a desired ideal response. "Best" here is defined by the minimax criterion: we want to minimize the maximum absolute error between the actual frequency response and the desired one.

To make this more flexible, we introduce a weighting function, , allowing us to specify that errors at some frequencies are more important than others. The weighted error function is:

where:

  • is the ideal or desired frequency response (e.g., 1 in the passband, 0 in the stopband).
  • is the frequency response of the actual FIR filter we are designing.
  • is the weighting function.

The goal is to find the filter coefficients that minimize over the frequency bands we care about.

Minimax Optimal FIR Filter Design

This video provides a concise introduction to the minimax design criterion. It formally defines the error function and the role of the weighting function.

Watch from 01:36 to 02:54. Focus on understanding the definition of the weighted error function and the core objective: minimizing the worst-case (maximum) error over a specified set of frequencies.

A remarkable property of filters that satisfy the minimax criterion is that their error is spread out evenly. The error oscillates with a constant maximum magnitude, , across the passband and stopband. This is why these filters are called equiripple filters.

This image illustrates the key characteristics of an equiripple filter designed using the Parks-McClellan method. The top plot shows the magnitude response with uniform ripples in the passband and stopband. The bottom plot shows the weighted error function, which oscillates between a maximum positive value and a maximum negative value .


2. The Alternation Theorem: The Mathematical Foundation

The reason optimal filters have this equiripple property is explained by a beautiful piece of mathematics called the Alternation Theorem.

First, it's important to recognize that the frequency response of a linear-phase FIR filter can be written as a sum of cosines, which is a type of trigonometric polynomial. For example, a Type I filter (odd length , even symmetry) has a frequency response of the form:

where are related to the impulse response coefficients . Designing the filter means finding the best set of .

The Alternation Theorem provides the precise condition that this best polynomial approximation must satisfy.

The Alternation Theorem states: For a Type I FIR filter with independent coefficients (e.g., ), the unique best approximation that minimizes the maximum weighted error is the one for which the error function exhibits at least extremal frequencies. At these frequencies, the error must reach its maximum magnitude and alternate in sign.

Minimax Optimal FIR Filter Design

The same video provides an excellent explanation of the Alternation Theorem and what it means in practice.

Please watch from 02:38 to 05:21. Pay close attention to the concept of extremal frequencies and the alternating nature of the error. The visual diagram at the end of this segment is particularly helpful for understanding this core principle.

The theorem is the key because it turns the abstract optimization problem ("find the best filter") into a concrete, testable condition ("find the filter whose error alternates times"). The Parks-McClellan algorithm is an iterative method designed to find exactly this filter.


3. The Parks-McClellan (Remez Exchange) Algorithm

The algorithm doesn't solve for the filter coefficients directly. Instead, it iteratively searches for the correct set of extremal frequencies. Once these are known, the filter and its error are uniquely determined. The algorithm is an application of the Remez exchange algorithm from approximation theory.

The steps are as follows:

  1. Guess: Choose an initial set of guessed extremal frequencies, . These are typically spread across the passband(s) and stopband(s).

  2. Solve: For this set of frequencies, we force the alternation property. We set up a system of linear equations with unknowns: the filter coefficients () and the error magnitude .

    This can be rearranged into a standard matrix form and solved.

*This image shows the structure of the system of linear equations that must be solved at each iteration of the algorithm. The matrix contains cosine terms evaluated at the guessed extremal frequencies, the unknown vector contains the filter coefficients and the error $\delta$, and the right-hand side contains the desired response values.*

3. Find Extrema: Using the filter coefficients found in Step 2, calculate the dense frequency response and the resulting error function over the entire frequency range. Then, find the actual local extrema of this error function.

  1. Exchange & Repeat: The new set of extrema found in Step 3 will likely be different from our initial guess. The "exchange" step involves replacing the old guessed extrema with these new ones. Now, we go back to Step 2 and repeat the process.

The algorithm converges (usually in a small number of iterations) when the extremal frequencies found in Step 3 are the same as the ones used in Step 2. At this point, the filter satisfies the Alternation Theorem and is therefore the optimal minimax filter.

Minimax Optimal FIR Filter Design

This final segment from the video walks through this iterative process, showing how the algorithm refines its guess for the extremal frequencies until it converges on the optimal solution.

Watch from 05:21 to 09:55. This section explains the iterative loop: guess frequencies, solve for coefficients, find the true extrema, and repeat. The diagram at 08:35 is excellent for visualizing the exchange step.

Test your understanding!

Suppose you are designing a Type I FIR filter of length . How many extremal frequencies must the error function of the optimal filter have, according to the Alternation Theorem?

Show answer

A Type I filter has odd length .
For , we have , which means , so .
The number of independent coefficients is .
The Alternation Theorem states that the error function must have at least extremal frequencies.
Therefore, the number of extrema is at least .


4. Practical Design Considerations

Using the Weighting Function

The minimax criterion minimizes the weighted error . This is extremely useful for controlling the trade-off between passband ripple () and stopband attenuation ().

The ripple in any band is inversely proportional to the weight in that band. If we want the stopband ripple to be 10 times smaller than the passband ripple , we must set the weight in the stopband to be 10 times larger than the weight in the passband. A common practice is to set and .

Minimax Optimal FIR Filter Design

This last clip explains how to use the weighting function to independently control passband and stopband ripple.

Watch from 09:55 to 11:32. This will clarify the practical use of the weighting function and also briefly touches on how filter order is chosen.

Historical Context and Modern Implementations

The Parks-McClellan algorithm was a major breakthrough in digital signal processing. It provided a systematic way to design the best possible FIR filters.

A modern implementation of the Parks-McClellan FIR ...

For some historical context and a look at modern implementations, this article is an excellent read. It connects the algorithm to its historical roots and discusses the details needed to create a robust implementation.

Please read the introduction and the second section titled 'The rest of this post...'. This will connect the algorithm to its origins (the Remez algorithm) and point you to the foundational academic papers by Parks, McClellan, and Rabiner, which fits your interest in deeper historical and mathematical context.

One key point from this reading is that the core algorithm is designed for Type I filters. Other filter types (Type II, III, and IV, for things like even-length filters, differentiators, or Hilbert transformers) are handled by cleverly transforming their design specifications into an equivalent Type I problem, solving it, and then transforming the resulting coefficients back. This demonstrates the power and generality of the underlying mathematical framework.


Conclusion

Today we delved into the principles behind optimal FIR filter design using the Parks-McClellan algorithm. This method stands in contrast to the more heuristic window and frequency sampling methods by providing a filter that is provably the best for a given length and design specification.

Key Takeaways:

  • The Parks-McClellan algorithm designs optimal equiripple FIR filters based on the minimax error criterion.
  • The filter is "optimal" in that it minimizes the maximum weighted error in the passband and stopband.
  • The design is mathematically guaranteed by the Alternation Theorem, which states the optimal filter's error must alternate at least times.
  • The algorithm is an iterative application of the Remez exchange algorithm, which finds the set of extremal frequencies that satisfies the theorem.
  • The weighting function is a powerful tool for controlling the relative ripple between different frequency bands (e.g., achieving higher stopband attenuation).

Preview of the Next Lesson:

We have now covered the three main FIR filter design paradigms: windowing, frequency sampling, and optimal equiripple design. We will now shift our focus from FIR filters to Infinite Impulse Response (IIR) filters. While FIR filters offer the advantages of guaranteed stability and linear phase, IIR filters can often achieve a similar magnitude response with a significantly lower filter order, making them much more computationally efficient. Our next lesson will begin by exploring the historical context of digital filter design, before we dive into methods for designing IIR filters, often by transforming classic analog filter prototypes into the digital domain.