Linear phase and group delay
لم يُترجم بعد؛ يُعرض باللغة الإنجليزية
عن هذا الدرس
A filter changes the size of each frequency, and it also delays it. Follow two packets, short bursts at 250 Hz and 750 Hz, through two filters with exactly the same gain. Filter A, the 21-tap Hamming lowpass from the windowing lesson, has mirror-image taps: its phase is a straight line, φ = −10ω, and both packets come out 10 samples (1.25 ms) late, together. Filter B, its minimum-phase twin, is quicker but delays them by 3.87 and 5.41 samples. You will meet phase delay and group delay, see why symmetry gives linear phase, and measure it with scipy. It builds on the frequency response and poles and zeros lessons, and on the Circuits lessons on filters and Bode plots.
Two packets of sound
A packet is a short burst of one sine wave. The source sends two at once: a low one at 250 Hz and a high one at 750 Hz, sampled 8000 times a second. The question: how late does each come out of a filter?
packet = a short burst of a sine wave
(one frequency, a smooth on and off)
low f = 250 Hz ω = 2π·250/8000 = 0.196 rad/sample
high f = 750 Hz ω = 2π·750/8000 = 0.589 rad/sample
fs = 8000 samples per second
1 sample = 0.125 msاقرأ الدرس خطوة بخطوة
Two packets of sound
A packet is a short burst of one sine wave. The source sends two at once: a low one at 250 Hz and a high one at 750 Hz, sampled 8000 times a second. The question: how late does each come out of a filter?
packet = a short burst of a sine wave (one frequency, a smooth on and off) low f = 250 Hz ω = 2π·250/8000 = 0.196 rad/sample high f = 750 Hz ω = 2π·750/8000 = 0.589 rad/sample fs = 8000 samples per second 1 sample = 0.125 msFilter A: mirror-image taps
Filter A is the 21-tap Hamming lowpass from the windowing lesson, cutoff 1000 Hz. Its taps are a mirror image around the middle one: h[n] = h[20 − n]. Fold the plot at n = 10 and the halves match.
y[n] = h[0]·x[n] + h[1]·x[n−1] + ... + h[20]·x[n−20] h[9] = 0.2200 h[10] = 0.2500 (the middle tap) h[11] = 0.2200 h[n] = h[20 − n] for every n: symmetric gain at 0 Hz = sum of taps = 1.004Every packet waits 10 samples
Send both packets through A. Each comes out exactly 10 samples (1.25 ms) after it went in, low and high alike. They arrive together, so a pulse or a sound made of both keeps its shape.
packet delay through A 250 Hz 10.00 samples = 1.25 ms 750 Hz 10.00 samples = 1.25 ms sizes change by the gain: |H| = 1.001 at 250 Hz, 0.807 at 750 Hz timing does not change between them motion: slowed down, n counted in samplesPhase falls in a straight line
Delaying a tone by D samples turns it by −ω·D radians. So A's phase is φ(ω) = −10ω: a straight line through zero. At 250 Hz that is −1.96 rad; at 750 Hz, −5.89 rad. This is linear phase.
pure delay of D samples: H(e^jω) = e^(−jωD), φ(ω) = −ωD filter A: φ(ω) = −10ω ω = 0.196 -> φ = −1.96 rad ω = 0.589 -> φ = −5.89 rad plot: φ unwrapped from 0 Hz (np.angle would wrap −5.89 to 0.39)Why mirror taps give a line
Pair the taps: h[0] with h[20], h[1] with h[19], and so on. Each pair sits the same distance either side of n = 10, so their two turns average to the middle one. Every pair points along e^(−j10ω).
one pair, k and 20 − k (equal taps): h[k]·e^(−jωk) + h[k]·e^(−jω(20−k)) = e^(−j10ω) · 2h[k]·cos(ω(10 − k)) add all pairs and the middle tap: H(e^jω) = e^(−j10ω) · A(ω), A(ω) real so φ = −10ω (plus π where A(ω) < 0, only in the stopband here)Group delay is the slope
Group delay is how late a packet's envelope arrives: τ(ω) = −dφ/dω, the downhill slope of the phase. A straight line has the same slope everywhere, so A gives τ = 10 samples at every frequency.
group delay τg(ω) = −dφ/dω (the envelope) phase delay τp(ω) = −φ(ω)/ω (the crests) filter A: φ = −10ω τg = 10 samples at every ω τp = 10 samples in the passband (in the stopband A(ω) < 0 adds π) linear phase: both equal and constant = the filter's delay, (L − 1)/2 = 10Filter B: same gains, lopsided taps
Filter B has exactly A's gain at every frequency. It was built from A's zeros, with those outside the unit circle flipped inside (a minimum-phase filter). Its taps bunch up at the start and are not symmetric.
zeros of A: 20 (np.roots) 12 on the unit circle (the stopband) 8 off it, in pairs r and 1/r flip each zero with |z| > 1 to 1/z* -> |H_B| = |H_A| at every frequency B taps: h[0] = 0.014, h[4] = 0.239 h[20] = 0.0005 (not a mirror)B is quicker, but uneven
Through B the 250 Hz packet takes 3.87 samples and the 750 Hz packet 5.41. Both arrive sooner than with A, but not together. B's phase curve bends, so its slope, the delay, changes with frequency.
packet delay through B 250 Hz 3.87 samples = 0.48 ms 750 Hz 5.41 samples = 0.68 ms spread 1.53 samples phase of B: −0.73 rad at 250 Hz −2.53 rad at 750 Hz not −ω·(one number): not linear uneven delay = phase distortionIn Python: group_delay
scipy.signal.group_delay takes a filter as (b, a) and the frequencies in hertz when you give fs. For filter A it prints 10 samples at both 250 and 750 Hz. np.sinc(m/4)/4 is the delayed ideal lowpass.
import numpy as np from scipy.signal import group_delay m = np.arange(21) - 10 h = np.sinc(m/4)/4 * np.hamming(21) group_delay((h, 1), [250, 750], fs=8000) (array([250., 750.]), array([10., 10.])) (h, 1): FIR, so a = 1 the twin B gives ≈ [3.87, 5.41] (Python 3 with numpy and scipy)The price is latency
A symmetric 21-tap filter always waits 10 samples (1.25 ms). Audio, ECG and data receivers pay that to keep shapes. Control loops often prefer a quick filter like B. Offline, filtfilt runs a filter forward then backward: zero phase.
symmetric L taps -> delay (L − 1)/2 samples 21 taps at 8000/s -> 1.25 ms linear phase (A): shapes kept, fixed delay minimum phase (B): least delay, uneven recorded data: scipy.signal.filtfilt forward, then backward in time the two phases cancel: zero phase (needs the whole signal first)
أسئلة سريعة: 5
اختر إجابة واحدة لكل سؤال. يمكنك تغيير اختياراتك قبل التحقق منها.
01A symmetric FIR filter has 31 taps. How many samples late does every frequency in its passband come out?
A symmetric filter with L taps has group delay (L − 1)/2 = 30/2 = 15 samples at every frequency.
02A filter's phase is φ(ω) = −6ω (radians, ω in rad per sample). What is its group delay at ω = 0.5?
Group delay is τ = −dφ/dω = −(−6) = 6 samples. A straight line has the same slope at every ω, so the value of ω does not matter.
03Which statement about filters A (symmetric) and B (its minimum-phase twin) is true?
Flipping zeros across the unit circle keeps |H| the same. B's delay is 3.87 samples at 250 Hz and 5.41 at 750 Hz, while A's is 10 at both.
04What does group delay measure for a narrow packet (a short burst of one frequency)?
The envelope is delayed by the group delay −dφ/dω; the crests inside move by the phase delay −φ/ω. For a linear-phase filter the two are equal.
05You must smooth a recorded ECG with no delay and no phase distortion. Which tool fits?
Running the filter forward and then backward in time cancels the phase: zero phase. It needs the whole recording first, so it works offline but not in real time.
المسرد
- Phase response φ(ω)
- The angle of H(e^jω): how far the filter turns a sine of frequency ω, in radians.
- Linear phase
- A phase that is a straight line, φ(ω) = −ωD: every frequency is delayed by the same D samples, so shapes are kept.
- Group delay τ(ω)
- −dφ/dω, the downhill slope of the phase: how many samples late the envelope of a narrow packet at ω comes out.
- Phase delay
- −φ(ω)/ω: how many samples late the crests of a single sine come out. Equal to the group delay when the phase is linear.
- Packet
- A short burst of one sine wave with a smooth start and end, so it holds a narrow band of frequencies.
- Symmetric FIR filter
- An FIR filter whose taps are a mirror image, h[n] = h[L − 1 − n]. It has linear phase with delay (L − 1)/2 samples.
- Minimum-phase filter
- A filter with all its zeros inside (or on) the unit circle. Among filters with the same gain it has the least group delay, but its delay changes with frequency.
- Zero phase (filtfilt)
- Filtering a recorded signal forward and then backward in time, so the two phase shifts cancel and nothing is delayed.
الملاحظات والمصادر
- Filter A is the Hamming-windowed 21-tap lowpass (cutoff 1000 Hz at 8000 samples a second) designed in the windowing lesson. Filter B is computed from A's zeros. Every number and curve in the figure is computed from these taps.
- A packet's envelope is delayed by the group delay at its frequency when the packet is narrow in frequency (Oppenheim and Schafer §5.1). The motion is slowed down and counted in samples.
- Symmetric taps with an odd length (Type I) are one of four kinds of linear-phase FIR filter: symmetric or antisymmetric taps, odd or even length. Where the real amplitude A(ω) changes sign the phase jumps by π, but the group delay stays (L − 1)/2.
- A. V. Oppenheim, R. W. Schafer, J. R. Buck, Discrete-Time Signal Processing, 2nd ed. (ch. 5: phase, group delay, minimum phase and linear phase; course text listed on MIT OCW 6.341 readings)
- MIT OpenCourseWare 6.003 Signals and Systems (D. Freeman, Fall 2011)
- Group delay and phase delay (Wikipedia): τg = −dφ/dω delays the envelope, τφ = −φ/ω the carrier
- Linear phase (Wikipedia): symmetric or antisymmetric FIR taps give exact linear phase
- Minimum phase (Wikipedia): zeros inside the unit circle, minimum group delay for a given magnitude
- J. O. Smith III, Introduction to Digital Filters, CCRMA: Linear Phase Really Ideal?
- SciPy documentation: scipy.signal.group_delay
- SciPy documentation: scipy.signal.filtfilt (forward and backward, zero phase)
- NumPy documentation: numpy.roots
- NumPy documentation: numpy.sinc (normalized, sin(πx)/(πx))
- NumPy documentation: numpy.hamming
اختبار يتاح بعد الخطوة الأخيرة.