# Weighting function for output error IIR filter design

I noticed, when I try to fit filter coefficients to a given complex transfer function with the output error method, implemented for example in the MATLAB function invfreqz.m, I get way better results when I use a weighting function that drastically emphasizes the lower frequencies, for example $1/(2\pi f)$.

Can anybody explain or give me a hint in the right direction, why emphasizing the low frequencies in the weighting function gives so much better fitting results?

My frequency vector is logarithmic, in case that makes a difference and I try to get the best fit for "relatively simple" transfer functions with a very low filter order.

## 1 Answer

The reason for the worse fit at low frequencies (without additional weighting) is the low density of frequency points at low frequencies due your choice of a logarithmic frequency vector. I'm pretty sure that you will get a better fit at low frequencies if you choose a (more) linear frequency grid.

• I'm sorry, but could you explain why i got more points at higher frequencies? When I check my frequency vector it seems to be the other way around, meaning more points in the lower frequency range. – user967493 Jun 12 '16 at 15:48
• @user967493: Ah, OK, I thought it might be the other way around because of the higher error at low frequencies, but you're right that normally there are more points at low frequencies for logarithmic spacing. In that case it would help if you uploaded the frequency vector and the vector of the desired complex frequency response together with your filter coefficients, so I can check what's going on. – Matt L. Jun 12 '16 at 16:07