Yet Another FIR Design Algorithm

Started by August 21, 2011
```Hello,

I wrote an algorithm that designs FIR filters. It can be found here
(OctaveForge / Matlab code):
http://www.dsprelated.com/showcode/210.php

In a nutshell, I generate both a test signal and the result I'd expect to
see from an ideal filter. I write out the FIR tap equations and find a LMS
solution for the tap coefficients.
The LMS solution is too "lazy" in the more "difficult" regions of the
frequency response, so I wrap it in an iteration loop that boosts the
signal where accuracy is lacking. After a couple of rounds, the outcome is
pretty much an equiripple design.

The advantage is that it's rather easy to design to arbitrary frequency
responses, including nonlinear phase, complex-valued FIR and fractional
delay. And so far, failure to convergence has not been an issue.

Comments (/bug reports) are welcome, and I hope you find it useful.

Cheers

Markus

```
```
mnentwig wrote:

> The LMS solution is too "lazy" in the more "difficult" regions of the
> frequency response, so I wrap it in an iteration loop that boosts the
> signal where accuracy is lacking. After a couple of rounds, the outcome is
> pretty much an equiripple design.

Hello Markus,

The LMS + dynamic programming approach converges to a solution however
this solution is generally not a global optimum. You can get similar
results using LMS to find initial guess and then numerically optimizing
the filter starting from that guess.

DSP and Mixed Signal Design Consultant
http://www.abvolt.com
```
```On Aug 21, 5:15&#2013266080;pm, Vladimir Vassilevsky <nos...@nowhere.com> wrote:
> mnentwig wrote:
> > The LMS solution is too "lazy" in the more "difficult" regions of the
> > frequency response, so I wrap it in an iteration loop that boosts the
> > signal where accuracy is lacking. After a couple of rounds, the outcome is
> > pretty much an equiripple design.
>
> Hello Markus,
>
> The LMS + dynamic programming approach converges to a solution however
> this solution is generally not a global optimum. You can get similar
> results using LMS to find initial guess and then numerically optimizing
> the filter starting from that guess.
>
> DSP and Mixed Signal Design Consultanthttp://www.abvolt.com

I tried the same algorithm some years ago only for iir filters using
the dual-fir equation error method.
It worked well except in the case where the ratio of sample rate to
cutoff frequency was very high.
Have you tried this? For example try a low pass with transition band
from
20 hz to 30 hz with 60 db stopband and fs of 50k.

Bob
```
```>It worked well except in the case where the ratio of sample rate to
>cutoff frequency was very high.

Maybe for this case the problem is not so much the method itself but could
be a numerical issue.
```
```>>It worked well except in the case where the ratio of sample rate to
>>cutoff frequency was very high.
>
>Maybe for this case the problem is not so much the method itself but
could
>be a numerical issue.

I think that most us would say that if there are numerical stability issues
with a method, the method has a problem.

Steve

```
```Hello,

thank you all for your reples.
I agree, there is no guarantee that it finds a global optimum. For example,
a small change in weights could cause zeros to "jump" from one passband to
another, making the weights from the last iteration meaningless.
I updated the description.

>> try a low pass with transition band from 20 hz to 30 hz with 60 db
stopband and fs of 50k

That's a long FIR filter... I tried 2000 taps and it behaves as expected,
but that comes nowhere close to the -60 dB at 30 Hz.
Maybe CPU power is more a limitation than numerical accuracy. I should
verify this, but I suspect the bottleneck is the pinv() on a (n taps) x (n
frequency bins) matrix in each iteration.

Kind Regards

Markus
```
```
mnentwig wrote:

> Hello,
>
> thank you all for your reples.
> I agree, there is no guarantee that it finds a global optimum. For example,
> a small change in weights could cause zeros to "jump" from one passband to
> another, making the weights from the last iteration meaningless.
> I updated the description.

If I am not mistaken, Dilip Sarwate was suggesting a similar approach to
manipulate weights using Greg Berchin's FDLS algorithm as a core LS
solver. That could allow for an arbitrary equiripple FIR/IIR design;
however I don't know how well did it work in reality.