DSPRelated.com
Forums

FIR filter design (false advertizing?)

Started by Paul Mennen February 29, 2004
Trying to design an FIR Low pass filter.
As a simple example, consider:

>> edge = [0 .3 .7 1]; >> weight = [100 1]; >> 1000*remez(7,edge,[1 1 0 0],weight)
ans= 32.2690 -109.2208 81.9170 495.0689 495.0689 81.9170 -109.2208 32.2690 The resulting filter has a pass band ripple of +/- .013dB and a stop band of -16.84dB. (The pass band is from DC to .3 and the stop band is from .7 to 1 where 1 represents Fs/2). Note that the impulse response is symmetric so this is a linear phase filter. This is expected because that is what REMEZ advertises itself as doing. However I know I can get better performance by removing the linear phase restriction. So now I try:
>> 1000*cremez(7,edge,'lowpass',weight,'real')
ans= 32.2466 -109.1672 81.8522 495.0968 495.0968 81.8522 -109.1672 32.2466
>> 1000*cremez(7,edge,'lowpass',weight,'even')
ans= 32.2466 -109.1672 81.8522 495.0968 495.0968 81.8522 -109.1672 32.2466 Note that both of these responses are just about exactly the same answer as given by REMEZ. From the help message (help cremez): REMEZ Complex and nonlinear phase equiripple FIR filter design. Yet I see only linear phase filters coming out of cremez. Isn't this false advertising? (I tried 'none' for the symmetry argument, but a complex filter comes out - clearly not what I am looking for.) The reason that I know that one can do much better than cremez is that by trial and error I came up with a filter with this impulse response: p = [307 535 307 -92 -113 43 29 -16]; I plotted the result with: plot(20*log10(abs(freqz(p,1,1000)))); Note the passband ripple is +/-.0126 dB (slightly better than before) and the stopband is -24 dB (much better than before!). Clearly not linear phase since it is not symmetrical, but I don't care about that. Any ideas why my trial and error approach does so much better than cremez? Any ideas on how to design such FIR filters without trial and error? I thought of using yulewalk, but that has some problems. Yulewalk is for iir filters, so right there it is at least twice as complicated as it should be. Also Yulewalk minimizes in the least squares sense and so it won't necessarily minimize the max deviation from desired. And finally Yulewalk doesn't allow a weighting function. ~Paul Mennen
Paul Mennen wrote:

> Trying to design an FIR Low pass filter. > As a simple example, consider: > > >>>edge = [0 .3 .7 1]; >>>weight = [100 1]; >>>1000*remez(7,edge,[1 1 0 0],weight) > > ans= 32.2690 -109.2208 81.9170 495.0689 495.0689 81.9170 -109.2208 32.2690 > > The resulting filter has a pass band ripple of +/- .013dB > and a stop band of -16.84dB. (The pass band is from DC to .3 > and the stop band is from .7 to 1 where 1 represents Fs/2). > > Note that the impulse response is symmetric so this is a linear phase > filter. This is expected because that is what REMEZ advertises itself > as doing. > > However I know I can get better performance by removing the linear > phase restriction. So now I try: > > >>>1000*cremez(7,edge,'lowpass',weight,'real') > > ans= 32.2466 -109.1672 81.8522 495.0968 495.0968 81.8522 -109.1672 32.2466 > > >>>1000*cremez(7,edge,'lowpass',weight,'even') > > ans= 32.2466 -109.1672 81.8522 495.0968 495.0968 81.8522 -109.1672 32.2466 > > Note that both of these responses are just about exactly the > same answer as given by REMEZ. > > From the help message (help cremez): > REMEZ Complex and nonlinear phase equiripple FIR filter design. > > Yet I see only linear phase filters coming out of cremez. > Isn't this false advertising? (I tried 'none' for the symmetry > argument, but a complex filter comes out - clearly not what > I am looking for.) > > The reason that I know that one can do much better than cremez > is that by trial and error I came up with a filter with this > impulse response: > > p = [307 535 307 -92 -113 43 29 -16]; > > I plotted the result with: plot(20*log10(abs(freqz(p,1,1000)))); > > Note the passband ripple is +/-.0126 dB (slightly better than before) > and the stopband is -24 dB (much better than before!). Clearly > not linear phase since it is not symmetrical, but I don't care > about that. > > Any ideas why my trial and error approach does so much better > than cremez? > > Any ideas on how to design such FIR filters without trial and error? > I thought of using yulewalk, but that has some problems. Yulewalk > is for iir filters, so right there it is at least twice as complicated > as it should be. Also Yulewalk minimizes in the least squares sense > and so it won't necessarily minimize the max deviation from desired. > And finally Yulewalk doesn't allow a weighting function. > > ~Paul Mennen
Paul, I'm not equipped to guess which program you're using. Do your resources limit you to 8 taps? Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
> Paul, > > I'm not equipped to guess which program you're using. Do your resources > limit you to 8 taps? > > Jerry
The design environment is of course Matlab, and the filters will be executed inside a floating pt. DSP chip. I'm not limited to 8 taps, but the example I gave is not the real problem. I just gave a simple example to illustrate the problem. Certainly I could get the performance required from a symmetrical FIR filter by increasing the order, but as with most filtering problems, one is trying to maximize the performance given certain timing or cost constraints. In this case, FIR would be easier but linear phase is not a requirement. That is why I was trying to figure out how to design non-linear phase FIR filters. ~Paul
Paul Mennen wrote:
> > The design environment is of course Matlab, and the filters > will be executed inside a floating pt. DSP chip. I'm not > limited to 8 taps, but the example I gave is not the real > problem. I just gave a simple example to illustrate the problem. > > Certainly I could get the performance required from a symmetrical > FIR filter by increasing the order, but as with most filtering > problems, one is trying to maximize the performance given certain > timing or cost constraints. In this case, FIR would be easier > but linear phase is not a requirement. That is why I was trying > to figure out how to design non-linear phase FIR filters.
If linear phase is not a requirement and you want to maximize the performance you would be better off with an IIR filter. Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ Linux: generous programmers from around the world all join forces to help you shoot yourself in the foot for free.
> If linear phase is not a requirement and you want to > maximize the performance you would be better off with > an IIR filter. > Erik
In general I agree with you, but in this particular situation I had a few reasons to prefer FIR filters. The main one was that hyper low noise was a requirement and this is easier to obtain with an FIR structure. Another factor was that one of the filter parameters is variable essentially requiring on-the-fly filter design capability. Generally FIR filter design is simpler than for IIR, although unless I figure out how to use cremez or similar technique, this advantage may not be realized. ~Paul
Dear Paul,

Try to add 1 sample to the impulse responce
and the results will be much better.
LPF FIR filters like the odd number of coefficients.

A.Ser.

Paul Mennen wrote:

> Trying to design an FIR Low pass filter. > As a simple example, consider: > > >> edge = [0 .3 .7 1]; > >> weight = [100 1]; > >> 1000*remez(7,edge,[1 1 0 0],weight) > ans= 32.2690 -109.2208 81.9170 495.0689 495.0689 81.9170 -109.2208 32.2690 > > The resulting filter has a pass band ripple of +/- .013dB > and a stop band of -16.84dB. (The pass band is from DC to .3 > and the stop band is from .7 to 1 where 1 represents Fs/2). > > Note that the impulse response is symmetric so this is a linear phase > filter. This is expected because that is what REMEZ advertises itself > as doing. > > However I know I can get better performance by removing the linear > phase restriction. So now I try: > > >> 1000*cremez(7,edge,'lowpass',weight,'real') > ans= 32.2466 -109.1672 81.8522 495.0968 495.0968 81.8522 -109.1672 32.2466 > > >> 1000*cremez(7,edge,'lowpass',weight,'even') > ans= 32.2466 -109.1672 81.8522 495.0968 495.0968 81.8522 -109.1672 32.2466 > > Note that both of these responses are just about exactly the > same answer as given by REMEZ. > > From the help message (help cremez): > REMEZ Complex and nonlinear phase equiripple FIR filter design. > > Yet I see only linear phase filters coming out of cremez. > Isn't this false advertising? (I tried 'none' for the symmetry > argument, but a complex filter comes out - clearly not what > I am looking for.) > > The reason that I know that one can do much better than cremez > is that by trial and error I came up with a filter with this > impulse response: > > p = [307 535 307 -92 -113 43 29 -16]; > > I plotted the result with: plot(20*log10(abs(freqz(p,1,1000)))); > > Note the passband ripple is +/-.0126 dB (slightly better than before) > and the stopband is -24 dB (much better than before!). Clearly > not linear phase since it is not symmetrical, but I don't care > about that. > > Any ideas why my trial and error approach does so much better > than cremez? > > Any ideas on how to design such FIR filters without trial and error? > I thought of using yulewalk, but that has some problems. Yulewalk > is for iir filters, so right there it is at least twice as complicated > as it should be. Also Yulewalk minimizes in the least squares sense > and so it won't necessarily minimize the max deviation from desired. > And finally Yulewalk doesn't allow a weighting function. > > ~Paul Mennen
> Dear Paul, > Try to add 1 sample to the impulse responce > and the results will be much better. > LPF FIR filters like the odd number of coefficients. > A.Ser.
Actually one can design FIR low-pass filters with an even number of coefficients just as well as with odd. At any rate, this is not relevent to the main problem of how to design FIR filters without the linear phase constriction. ~Paul


> > Dear Paul, > > Try to add 1 sample to the impulse responce > > and the results will be much better. > > LPF FIR filters like the odd number of coefficients. > > A.Ser. > > Actually one can design FIR low-pass filters with an even number > of coefficients just as well as with odd. At any rate, this is > not relevent to the main problem of how to design FIR > filters without the linear phase constriction. > > ~Paul
Of course, it is not a problem. The problem is how to get from FIR filter that you want. Another words, the optimization problem is. And here the algorithms like REMEZ often can give very bad results because it optimizes not the max. error but the mean square error. Sometimes one has to adapt himself to the algorithm optimization behave. And here odd filter lengths can be better than even ones for the given characteristics. A.Ser.
> Of course, it is not a problem. > The problem is > how to get from FIR filter that you want. > Another words, > the optimization problem is. > And here the algorithms like REMEZ > often can give very bad results > because it optimizes not the max. error > but the mean square error. > Sometimes one has to adapt himself to > the algorithm optimization behave. > And here odd filter lengths can be better than even ones > for the given characteristics. > > A.Ser.
Some optimization techniques (such as the one used in FIRLS for example) do minimize the mean square error, however others (such as remez and cremez) do actually minimize the maximum deviation from the desired response. ~Paul
"v" <yes@i.am> wrote in message news:4043376A.8CD98C21@i.am...

.....................
> And here the algorithms like REMEZ > often can give very bad results > because it optimizes not the max. error > but the mean square error.
......................>
> A.Ser. >
A. Ser., Well, I suppose that one could label *any* algorithm improperly. However, the Remez exchange algorithm *is* directed at minimizing the maximum error. Now, I can't vouch for what may be in Matlab or any other "collection" with such labels attached. Nonetheless, I've never seen a counter example. Fred