# Difference Between Equiripple & Least Squares Design for FIR Digital Filters

For an efficient and optimized digital FIR filter design, there are two methods available broadly, Equiripple filter design & Least Squares filter design. A general method for designing a filter is also Frequency Sampled FIR design but it is not an optimized design

The basic knowledge I have is that Equiripple filter, as the name suggests, has equal ripples in passband & stopband, which means the signal distortion that happens at the edge of the passband due to presence of a large ripple is avoided in Equiripple design BUT, Equiripple design has a large transition band, thus limiting the total passband width.

On the other hand, in a Least Squares design, the transition band width is smaller than for Equiripple design, hence the passband width is more, but the passband ripple are not equi-ripple & exhibit a spike at the passband edge due to Gibbs phenomenon, which causes signal distortion at the edge.

My question is can somebody present or quote the all the differences & advantages over other, in a technical language, for the Equiripple design vs Least squares design of digital low pass FIR filter.

• what @JasonR said. the equiripple design (Parks-McClellan) will have less maximum error than the least-squares design at the expense of having more mean-square error. also it should be noted that weighting factors can be applied and the equiripple design need not require that passband ripple be the same as the stopband ripple. Commented May 22, 2014 at 5:54
• @robertbristow-johnson I also want to know what's the effect on signal in the case of these two, in terms of distortion. Is it that equal ripple has uniform albeit larger distortion & least squares has smaller albeit non liner distortion. Also which is preferred Commented May 22, 2014 at 6:15
• well, filters, in and of themselves, don't distort. whether they have ripple or not. FIRs designed with either Parks-McClellan or Least-Squares, are linear-phase as well as just linear (as in "LTI"). Commented May 24, 2014 at 5:15

While I completely agree with Jason R's answer, I would like to add a few things that I consider important. First of all, it is a misunderstanding to believe that for least squares designs the transition band width is smaller than for equi-ripple designs. The width of the transition band depends on many design parameters but it is independent of the optimality criterion. With both criteria you can define arbitrary transition bands ("don't care regions") where you simply do not specify a desired response. This has to be done explicitly for the Parks-McClellan algorithm, but it can (and should) also be done for least squares designs. The most basic least squares design which is to simply truncate the Fourier series of a (often discontinuous) desired frequency response, is definitely no benchmark for comparing least squares designs with other optimality criteria.

The second important thing to notice is that the least-squares design and the equi-ripple design are two extreme points on a trade-off curve between maximum error and error energy. While the least squares design minimizes the error energy, its maximum error is relatively large, and the opposite holds for the equi-ripple design. So it is desirable - and possible - to mix the two criteria. One way of doing this is to use a constrained least squares criterion which minimizes the error energy while constraining the maximum error to some desired limit. In many cases it is desirable to have an equi-ripple design in the passband of a filter and to minimize the (weighted) least squares error in the stopbands, because then the maximum distortion of the signal is minimized, while the noise power in the stopbands is also minimized. The following example shows such a design. It is a linear-phase FIR bandpass filter of order 100, with a constraint on the maximum error in the passband (in this case resulting in an equi-ripple design in the passband), and with minimal error energy in the stopbands. The top figure shows the magnitude of the frequency response in dB, and the bottom figure shows the magnitude of the frequency response in the passband. Clearly, we have an equi-ripple approximation in the passband, and a least squares approximation in the stopbands.

• Hi Matt: I don't suppose you could provide a resource for generating these filters - I find it really interesting, and would like to know more. Commented Jan 13, 2016 at 14:21
• @TomKealy: Sure I can. It's in my thesis. Commented Jan 13, 2016 at 14:26
• @MattL., Looks very interesting. Is there a MATLAB Code for those? Thank You.
– Royi
Commented Aug 16, 2016 at 8:34
• @Drazick: Yes, in my profile you can find the link to my site; there go to 'PhD thesis' where you'll find a download link for the matlab files. Note that they are VERY old, and you might need to change a few things to adapt them to the Matlab / Octave version you use. On my site you'll also find an email address, in case you have any questions. Commented Aug 16, 2016 at 8:59

One main difference is the cost function used in the two design methods:

• Equiripple filters seek to minimize the maximum error between the desired filter response and the designed approximation.

• Least-squares filters seek to minimize the total squared error betwen the desired filter response and the designed approximation.

These different strategies lead to the different characteristics observed in the two methods' results, a number of which you noted in your question.

Here are some additional points FWIW.

In filter design the peak sidelobe level (PSL) is an important stopband parameter because it is going to decide the worst-case attenuation. For example, the PSL of Hann-window based LPF is $$-43.9$$ dB, whereas for the Hamming-window based LPF it is $$-54.5$$ dB. Hence, the latter is preferred for filter design. Note that the roll-off for these are quite different: $$-6$$ dB/oct for Hamming and $$-18$$ dB/oct for Hann. Hence, the latter is far better suited for spectral estimation (because its faster roll-off will allow nearby weaker sinusoids to show up in the spectrum, unlike the Hamming window). The faster roll-off is inconsequential in filter design because it is the PSL that decides the worst-case attenuation.

For a given window length N,the energy should be normalized for fair comparison between different designs. Hence, if we try to reduce the energy in one region, it has to pop up elsewhere. With this in mind, since the PSL is the crucial parameter as far as stopband performance is concerned, it is intuitively clear that if we make all the sidelobes to be of the same height. we can forego roll-off. Roll-of is a double whammy: not only is it unhelpful in filter design, but also reduces the energy in those regions, which energy has to pop up elsewhere. The transition region is the one that takes the hit in absorbing this energy from the stopband. This also explains why window-based LPFs that are designed using ones having less abrupt transitions have better PSL's but at the cost of wider transition.

OTOH if we make all the sidelobes equiripple, the increased energy in them can be drawn away from the transition region. Thus, equiripple filters have the narrowest transition region among all filters having the same length and specifications. It is a natural consequence of using the minimax error as the criterion. Hence, if an equiripple design is available, that would be the best among all other design choices such as window-based, least-squares, etc.

Note that the Chebyshev window, which is equiripple, is optimal as far as windwos go, but an LPF desinged using this window is not optimal. This is because it loses its equiripple nature after convolution (in the frequency domain) with the ideal LPF's frequency response.