Berchin's FDLS arbitrary filter design algorithm I'm trying to use Berchin's FDLS methods (for those that don't know what it is, it's a way to design arbitrary magnitude and phase of an IIR Eq)

I tried different things but neither gave me what i asked:


I tried to design an allpass filter with arbitrary phase response (nothing fancy just a linear phase and a short deviation for 5 points) and it didn't worked as planned. Actually what i want to do is to counter the phase change of an IIR filter
I tried a linear phase response for a $-12\textrm{ dB}$ notch and the same way it didn't worked (in black the desired response)



I used a samplerate of $316$, $M=158$ points and a filter order of around $50$.


Do I need to use more points to increase the filter order or is it just impossible to design my filters using that algorithm?
FDLS requires a causal frequency response. Your prototype frequency response has zero phase everywhere, which is most definitely not causal.

An IIR filter order of 50 is humongous. When FDLS has too many poles and zeroes available, it "tries" to cancel excess poles with excess zeroes. Unfortunately, due to numerical limitations, the cancellation is often pretty poor. For your notch filter, try 2nd or 4th order numerator and denominator, after making the response causal.

Though (number of measurements) = (number of coefficients) = [(numerator order) + (denominator order) + 1] is mathematically sufficient, I find that FDLS likes many more measurements than that. I recommend an absolute minimum of twice as many measurements as coefficients, and prefer 5x to 10x.

Greg Berchin