# IIR filter group delay

I've designed an IIR bandpass elliptic filter in Scilab with the following parameters.

1. Sampling Frequency = 25000 Hz
2. Lower cutoff frequency = 100 Hz
3. Upper cutoff frequency = 150 Hz
4. Pass band ripple = stop band ripple = 0.001 ~ 0.005 dB

When I compute the group delay of this filter, I get a value of about 31 samples at a frequency of 125 Hz.

However, when I filter a 125Hz signal using the flts function, I see that the delay doesn't really line up with the number 31.

If the group delay was 31 samples, shifting the output signal back by that number would align it with the input signal which is the behavior I've seen with all FIR filters (N -1 / 2). Of course, the group delay doesn't vary with frequency in FIR filters but I'm looking at just this one frequency (125 Hz) at the moment.

Is the group delay correct? If so, why wouldn't the output align with the input if it is shifted? Given below is the full Scilab code.

Fs = 25000;
Flp = 100;
Fhp = 150;

filterTf = iir(3,'bp','ellip',[Flp/Fs Fhp/Fs],[0.001 0.005]);

figure("BackgroundColor",'1|1|1');
bode(syslin(1/Fs,filterTf),0.01:0.05:Fs/2);

t = 0 : 1/Fs : 0.1;
inputSignal = 10 * sin(2 * %pi * 125 * t);
filteredSignal = flts(inputSignal,filterTf);

figure("BackgroundColor",'1|1|1');
xtitle('Signals','Samples','Signals');
plot(inputSignal,'r-','LineWidth',2);
plot(filteredSignal, 'k-','LineWidth',2);
legend(["Input Signal";"Filtered Signal"],"out_upper_right");
xgrid(1);

figure("BackgroundColor",'1|1|1');
[tg,fr] = group(25000,filterTf);
plot(fr,tg);
xgrid(1);

• Whenever you get inconsistencies like these, the only way to actually measure the group delay is the transient analysis, not the frequency one. Simply run a sine and measure the delay. In this case, 125Hz is close to \$\sqrt{100*150}\$ which means that, for a bandpass filter, the phase is zero at the center frequency, so at 125Hz it will be a few degrees, thus a minimal delay. See also the suggestions on the right about negative group delay. – a concerned citizen May 28 '18 at 7:47
• Is there a way to obtain the group delay for a range of frequencies by expanding this method? I also tried the differential of the phase angle method but I don't see any negative group delay which I do see in the transient analysis method that you suggested. My goal is to design an all pass group delay equalization filter for the pass band region, so I need the group delays for the entire pass band & not just one frequency. – Sunny Yates Jun 2 '18 at 18:12
• Sure, why not? You just have to do a fairly slow sweep, to avoid transients from very undamped systems (like Chebyshev, Cauer, etc), and to be able to properly measure the delays. You could also do it with fixed frequencies, like a table, pick your choice. – a concerned citizen Jun 2 '18 at 20:15