Sign in

username:

password:



Not a member?

Search blogs



Search tips

Articles by category

Our Bloggers

DSP Blogs > Rick Lyons > Computing the Group Delay of a Filter

Rick Lyons
Richard (Rick) Lyons is a consulting Systems Engineer and lecturer with Besser Associates in Mountain View, California. He is the author of "Understanding Digital Signal Processing 2/E" (Prentice-Hall, 2004), and Editor of, and contributor to, "Streamlining Digital Signal Processing, A Tricks of the Trade Guidebook" (IEEE Press/Wiley, 2007). He is also an Associate Editor for the IEEE Signal Processing Magazine.

RSS Feed

Would you like to be notified by email when Rick Lyons publishes a new blog?

  

Computing the Group Delay of a Filter

Posted by Rick Lyons on Nov 19 2008 under Tips and Tricks   

I just learned a new method (new to me at least) for computing the group delay of digital filters. In the event this process turns out to be interesting to my readers, this blog describes the method. Let's start with a bit of algebra so that you'll know I'm not making all of this up.

Assume we have the N-sample h(n) impulse response of a digital filter, with n being our time-domain index, and that we represent the filter's discrete-time Fourier transform (DTFT), H(ω), in polar form as:

      (1)

In Eq. (1), M(ω) is the frequency magnitude response of the filter, Φ(ω) is the filter's phase response, and ω is continuous frequency measured in radians/second. Taking the derivative of H(ω) with respect to ω, we have:

      (2)

Dividing Eq. (2) by M(ω), we write:

      (3)

Performing the derivative of the first term on the right side of Eq. (3) gives us:

      (4)

Multiplying both sides of Eq. (4) by j/ejΦ(ω) yields:

      (5)

So now what does that puzzling gibberish in Eq. (5) tell us? As it turns out, it tells us a lot if we recall the following items:

 

  • jd[H(ω)]/dω = the DTFT of n·h(n)
  • M(ω)•ejΦ(ω) = H(ω) = the DTFT of h(n)
  • –d[Φ(ω)]/dω = group delay of the filter.

 

Now we are able to translate Eq. (5) into the meaningful expression

      (6)

Discretizing expression (6) by replacing the DTFT with the discrete Fourier transform (DFT), we arrive at what I recently learned about computing the group delay of a digital filter:

      (7)

So, starting with a filter's N-sample h(n) impulse response, performing two N-point DFT's and an N-sample complex division, we can compute the filter's group delay measured in samples. (Of course, to improve our group delay granularity we can zero pad our original h(n) before computing the DFTs). The advantage of the process in expression (7) is that the phase unwrapping process needed in traditional group delay algorithms is not needed here.

WARNING Will Robinson: in implementing the process in expression (7) you must be prepared to accommodate the situation where a frequency-domain DFT[h(n)] sample is zero-valued.

Below is a bit of MATLAB code that can be used to demonstrate the process in expression (7).

clear, clc
Npts = 128;  % Number of plotting points

% Define filter feedforward & feedback coefficients
  B = [0.03, 0.0605, 0.121, 0.0605, 0.03]; 
  A = [1, -1.194, 0.436];  

  Imp_Resp_Length = 40;
  [Imp_Resp,n] = impz(B,A,Imp_Resp_Length);
  ImpResp_times_Time = Imp_Resp.*n;
  [Freq_Resp, W] = freqz(Imp_Resp, 1, Npts, 'whole');
  [Deriv_of_Freq_Resp, W] = freqz(ImpResp_times_Time, ...
      1, Npts, 'whole');
  
  Grp_Delay = real(Deriv_of_Freq_Resp./Freq_Resp);
  Grp_Delay = fftshift(Grp_Delay);
  Freq = (W-pi)/(2*pi);  % Freq axis vector

  figure(1), clf
  subplot(2,1,1)
  plot(n, Imp_Resp, '-ks', ...
        n, ImpResp_times_Time, '-bs', 'markersize', 4)
  legend('h(n)','n times h(n)');
  ylabel('Amplitude'), xlabel('n'), grid on, zoom on
  subplot(2,1,2)
  plot(Freq, Grp_Delay,'-rs', 'markersize', 4)
  ylabel('Group Delay (samples)')
  xlabel('Freq x Fs   (Fs = sample rate)')
  grid on, zoom on


Rate this article:
3.665
Rating: 3.67 | Votes: 3
 
posted by Rick Lyons
Richard (Rick) Lyons is a consulting Systems Engineer and lecturer with Besser Associates in Mountain View, California. He is the author of "Understanding Digital Signal Processing 2/E" (Prentice-Hall, 2004), and Editor of, and contributor to, "Streamlining Digital Signal Processing, A Tricks of the Trade Guidebook" (IEEE Press/Wiley, 2007). He is also an Associate Editor for the IEEE Signal Processing Magazine.

Previous post by Rick Lyons: Computing Large DFTs Using Small FFTs
Next post by Rick Lyons: Free DSP Books on the Internet - Part Deux
all articles by Rick Lyons

Would you like to be notified by email when Rick Lyons publishes a new blog?

  


Comments


 

JOS wrote:

11/19/2008
 
For related discussion, see
http://www.dsprelated.com/dspbooks/filters/Numerical_Computation_Group_Delay.html

 

Sasha Case wrote:

11/20/2008
 
This is a cool trick that is also used in the built-in Matlab function grpdelay.m. The comments for grpdelay.m refer to it as:

% The Smith algorithm is employed for FIR filters
% - unpublished algorithm from J. O. Smith, 9-May-1988
% - faster than the Shpak algorithm, best suited to FIR filters

We've been looking at group delay recently as well, for signals defined circularly (ie. we consider a repeating sequence of samples). How is group delay defined for an infinitely repeating sequence? The frequency domain representation consists of complex delta-functions - what does it mean to differentiate this? Our conclusion was that group-delay only makes sense for a finite sequence of samples.
 

Rick Lyons wrote:

11/23/2008
 
To J.O. Smith:
Thanks for the link to your educational 'group delay' material. As it turns out, I learned that group delay estimation method from one of the "exercises" in your Prof. Burris' book: "Computer-Based Exercises for Signal Processing Using MATLAB".
(That book deserves much more recognition than it has received thus far.)

By the way, I also worked (in building M4) for ESL in Sunnyvale. But I think I started at ESL after you departed. It's a good thing you weren't there the afternoon, in February 1988, when Richard Farley went on his rampage.
(http://en.wikipedia.org/wiki/Richard_Farley)

Regards,
[-Rick Lyons-]

 

Rick Lyons wrote:

11/24/2008
 
To Sasha Case:
Humm, ... I've never considered the scenario that you describe. Group delay is a characteristic of the Fourier transform of a discrete network's impulse response. Now if you're considering an impulse response that's an infinitely-repeating sequence, wouldn't that network be more correctly called an "oscillator" rather than a "filter"? Off the top of my head I'd say that the notion of 'group delay' has no meaning when talking about oscillators. My guess is that your conclusion is correct.

Regards,
[-Rick-]

Add a Comment
You need to login before you can post a comment (best way to prevent spam). ( Not a member? )