A couple of second order notch filters seem to be appear regularly in the literature (see e.g., Tseng, Chien-Cheng, and Soo-Chang Pei. "Stable IIR notch filter design with optimal pole placement." IEEE Transactions on Signal processing 49.11 (2001): 2673-2681) and Dan Boschen's response to Transfer function of second order notch filter):

$$H_1(z^{-1})=\frac{1-2\cos(\omega)z^{-1} + z^{-2}}{1-2\rho\cos(\omega)z^{-1} + \rho^2z^{-2}}$$

where $\omega$ is the notch frequency and $\rho$ is a positive constant near (but less than) one.

A different notch mentioned in Cheng's paper is:

$$H_2(z^{-1}) = \frac{1}{2}(1 + G(z^{-1}))$$ $$G(z^{-1}) = \frac{\rho^2 - (1-\rho^2)\cos(\omega)z^{-1} + z^{-2}}{1- (1-\rho^2)\cos(\omega)z^{-1} + \rho^2 z^{-2} }$$

where $G(z^{-1})$ is all-pass.

These filters can produce sharp notches (especially as $\rho \rightarrow 1$), but the group delay response is highly nonlinear. Of course, group delay variation deep in the notch doesn't matter. However, in my application such variation around the notch is undesirable.

As an example, consider $H_1(z^{-1})$ for $\rho=0.98$ when $f_s=2$ and $f=0.163$ ($\omega=2\pi f/f_s$):

enter image description here

There is significant variation outside say $0.163\pm0.0163$.

I would like to equalize group delay variation outside some range $f\pm \delta$ around the notch. Are there any standard approaches to this (short of having to dump the IIR notch entirely and use instead a potentially very long FIR filter with more favorable phase response)? I suppose that using, e.g., Matlab's arbitrary magnitude and phase filter design tool, I could get an FIR filter that would equalize the group delay response or iirgrpdelay for an IIR filter. Wondering if that's my best bet?

  • $\begingroup$ Curious that you're worried about non-constant group delay around the frequencies that are attenuated in the notch filter. Who cares what happens to the phases (or delays) of sinusoids that are mostly eliminated? $\endgroup$ Jan 11 at 5:39
  • 1
    $\begingroup$ @robertbristow-johnson. Yes, I recognize that what happens where there's significant attenuation doesn't matter. But in my plot, even looking only at areas with less than 0.5dB attenuation, there's pretty significant variation. Ultimately, I care because I'm going to need to cascade several of these to notch multiple nearby frequencies while preserving what's in between. Wondering if I should delete this question and pose the full question. Didn't want to over complicate things. $\endgroup$
    – rhz
    Jan 11 at 6:12
  • $\begingroup$ Don't delete the question. If "pos[ing] the full question" means another question, why not just modify this one to be whatever is the "full question" you want to pose? $\endgroup$ Jan 11 at 13:36

1 Answer 1


Yes if you have access to Matlab's arbitrary magnitude and phase tool, that is certainly a good bet.

Other approaches if you want to get more into the design details are:

As an IIR solution, see the Least Squares equation method detailed by MattL, see his blog post on this. He may provide further details on this here on StackExchange as an answer. In his post he provides a simple example demonstrating using least squares for group delay equalization.

As an FIR solution for arbitrary phase and magnitude response filters, you can use the Frequency Sampling method which is to oversample in the frequency domain the desired compensation response you want to achieve as DFT values (starting at bin 0 and going to bin N-1 as one sample less than the sampling rate, and ensuring complex conjugate symmetry if you want real filter coefficients- or realize if you want to compensate for a response that doesn't have such symmetry that complex coefficients will be required!), take the inverse DFT of that (evaluate the result to ensure you are not subject to time domain aliasing: if the tails of the filter haven't sufficiently decayed then you need to use more samples in the frequency domain. As far as "sufficiently decayed", I look at that on a dB scale compared to the dynamic range I am working in). The resulting oversampled inverse DFT impulse response result may need to be circularly rotated to be the causal filter coefficients needed to create the filter. Also, as in the IIR solution above, additional linear phase may need to be added in the frequency domain to be realizable. This takes an understanding of time delay and frequency phase response relationships, filter causality etc but if things aren't looking right, this is often the reason. Once the impulse response is established, this can then be down-sampled to be the coefficients for the compensation filter. Windowing the final result will reduce truncation effects, resulting in reduced frequency domain ripple and can help reduce the total number of coefficients needed further if that is a concern.

As far as using 2nd order all-pass sections specifically to make arbitrary group delay corrections: the group delay that we get from the all-pass is a very specific "resonant shape" that we have little control over other than setting the center frequency by setting the radius of the poles and zeros, and the peak delay by setting the proximity to the unit circle. To be an all-pass, the zeros must be at the conjugate reciprocal location of the poles ($z_{zero} = 1/z^*_{pole}$). As the delay increases, the width of the resonant shape decreases and the width and height cannot be controlled independently. The graphic below is a copy of a demonstration tool I made recently showing this, where the radius and phase of the pole-zero pair can be adjusted while the phase and group delay resposne are observed.


From this we can get an intuition as to why several 2nd order sections would be required to compensate for the group delay of a single 2nd order IIR notch filter (which has a similar group delay peak as the OP has shown), and how the overall delay will need to be increased. We are limited to the basic group delay shape as in the plot above for each compensation section, and with multiple sections in series can ultimately sample an arbitrary desired delay response. We should also see how challenging this would be to do manually without use of an optimization / search algorithm for optimum placement of the multiple pole-zero pairs needed.

Below shows an example of using 7 2nd order IIR allpass functions to approximate a desired optimum group delay compensation response shown in blue for an IIR Cauer passband filter. The green-yellow ripple is the combined response for each of the individual sections also shown. Here we see how each of the individual sections is the "resonant" shape introduced above, and with the correct frequency setting and magnitude we are able to approximate an arbitrary shape.

Group Delay equalization

  • $\begingroup$ Would matlab's arbitrary mag/phs tool be preferable to iirgrpdelay? Also, in those designs, will adding in extra constant group delay improve group delay equalization (obviously at the expense of additional delay)? $\endgroup$
    – rhz
    Jan 11 at 16:48
  • $\begingroup$ I haven't seen under the hood of the fdesign.arbmagphase tool (arbitrary mag/phs) but my understanding is this: I believe the iirgrpdelay is the least squared solution similar to the custom function that MattL describes in his post, and will return an iir filter solution, and optimum for the given order, when it is able to converge. I suspect the arbitrary mag/phs tool in addition to giving both FIR (which is likely the frequency sampling approach I described) and IIR solutions, has further optimization approaches for when the least squares solution isn't resolvable. $\endgroup$ Jan 11 at 18:36
  • $\begingroup$ If you want an IIR solution, try the iirgrpdelay function first as that is simplest/straightforward and if the result is not adequate or you want an FIR solution go to fdesign.arbmagphase. (or just do the frequency sampling approach using the IFFT and windowing that I described). $\endgroup$ Jan 11 at 18:37
  • $\begingroup$ Makes sense. Again, on top of attempting to compensate for variations in group delay, it seems that there will be a constant delay imparted by the group delay equalizer which I can set by adding a linear term to the target phase response. Should that be set to be as large as acceptable to be get the best equalization? $\endgroup$
    – rhz
    Jan 12 at 4:27
  • $\begingroup$ Yes that's right. With some solutions you get to see the full impulse response extending to plus and minus time in which case it's clear how to add delay and make it causal. Other cases (depending on approach) the time domain aliases which the skilled eye can recognize--- but if you start to add delay in small increments and see how the impulse response (filter coefficients for an FIR case) moves that will also start to make sense. In some cases too much delay can also make it not converge. $\endgroup$ Jan 12 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.