LINEAR-PHASE FIR FILTERS
1. The amplitude response
2. Why linear-phase?
3. The four types of linear-phase FIR filter
4. Amplitude response characteristics
5. Evaluating the amplitude response
6. Zero locations of linear-phase filters
7. Automatic zeros
8. Design by DFT-based interpolation
9. Design by general interpolation
I. Selesnick EL 713 Lecture Notes 1 THE AMPLITUDE RESPONSE
If the real and imaginary parts of Hf (ω) are given by
Hf (ω) = R(ω) + j · I(ω) the magnitude and phase are defined as
|Hf (ω)| = pR2(ω) + I2(ω) I(ω) p(ω) = arctan R(ω) so that
Hf (ω) = |Hf (ω)| · ejp(ω).
With this definition, |Hf (ω)| is never negative and p(ω) is usually discontinuous, but it can be very helpful to write Hf (ω) as
Hf (ω) = A(ω) · ejθ(ω) where A(ω) can be positive and negative, and θ(ω) continuous. A(ω) is called the amplitude response. The figure illustrates the difference between |Hf (ω)| and A(ω).
I. Selesnick EL 713 Lecture Notes 2 THE AMPLITUDE RESPONSE (2)
|H(ω)| = |A(ω)| Phase{H(ω)} 1.4 4
1.2 2 1
0.8 0 0.6
0.4 −2 0.2
0 −4 0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1 ω/π ω/π
A(ω) θ(ω) 1.2 0
1 −5 0.8
0.6 −10 0.4
0.2 −15 0
−0.2 −20 0 0.2 0.4 0.6 0.8 1 0 0.2 0.4 0.6 0.8 1 ω/π ω/π
A linear-phase phase filter is one for which the continuous phase θ(ω) is linear.
Hf (ω) = A(ω) ejθ(ω) with
θ(ω) = −M · ω + B.
We assume in the following that the impulse response h(n) is real- valued.
I. Selesnick EL 713 Lecture Notes 3 WHY LINEAR-PHASE?
If a discrete-time cosine signal
x1(n) = cos(ω1 n + φ1) is processed through a discrete-time filter with frequency response
Hf (ω) = A(ω) · ejθ(ω) then the output signal is given by
y1(n) = A(ω1) cos(ω1 n + φ1 + θ(ω1)) or θ(ω1) y1(n) = A(ω1) cos ω1 n + + φ1 . ω1 The LTI system has the effect of scaling the cosine signal and de- laying it by −θ(ω1)/ω1.
When does the system delay cosine signals with different frequencies by the same amount?
θ(ω) =⇒ = constant ω
=⇒ θ(ω) = K ω
=⇒ The phase is linear
The function θ(ω)/ω is called the phase delay. A linear phase filter therefore has constant phase delay.
I. Selesnick EL 713 Lecture Notes 4 WHY LINEAR-PHASE: EXAMPLE
Consider an discrete-time filter described by the difference equation
y(n) = − 0.1821 x(n) + 0.7865 x(n − 1) − 0.6804 x(n − 2) + x(n − 3) + 0.6804 y(n − 1) − 0.7865 y(n − 2) + 0.1821 y(n − 3).
When ω1 = 0.31 π, then the delay is −θ(ω1)/ω1 = 2.45. The delay is illustrated in the figure:
2
1.5
1
0.5
0
−0.5 (n) (INPUT)
1 −1 x −1.5
−2 20 22 24 26 28 30 32 34 36 38 40
2
1.5
1
0.5
0
−0.5
(n) (OUTPUT) −1 1
y −1.5
−2 20 22 24 26 28 30 32 34 36 38 40
Notice that the delay is fractional — the discrete-time samples are not exactly reproduced in the output.
The fractional delay can be interpreted in this case as a delay of the underlying continuous-time cosine signal.
I. Selesnick EL 713 Lecture Notes 5 WHY LINEAR-PHASE: EXAMPLE (2)
Consider the same system given on the previous slide, but let us change the frequency of the cosine signal.
When ω2 = 0.47 π, then the delay is −θ(ω2)/ω2 = 0.14.
2
1.5
1
0.5
0
−0.5 (n) (INPUT)
2 −1 x −1.5
−2 20 22 24 26 28 30 32 34 36 38 40
2
1.5
1
0.5
0
−0.5
(n) (OUTPUT) −1 2
y −1.5
−2 20 22 24 26 28 30 32 34 36 38 40
For this example, the delay depends on the frequency, because this system does not have linear phase.
I. Selesnick EL 713 Lecture Notes 6 WHY LINEAR-PHASE: MORE
From the previous slides, we see that a filter will delay different frequency components of a signal by the same amount if the filter has linear phase (constant phase delay).
In addition, when a narrow band signal (as in AM modulation) goes through a filter, the envelop will be delayed by the group delay or envelop delay of the filter. The amount by which the envelop is delayed is independent of the carrier frequency only if the filter has linear phase. (See page 214 in Mitra.)
Also, in applications like image processing, filters with non-linear phase can introduce artifacts that are visually annoying.
I. Selesnick EL 713 Lecture Notes 7 FOUR TYPES OF LINEAR-PHASE FIR FILTERS Sec 4.4.3 in Mitra Linear-phase FIR filter can be divided into four basic types. Type impulse response I symmetric length is odd II symmetric length is even III anti-symmetric length is odd IV anti-symmetric length is even
TYPE I IMPULSE RESPONSE TYPE II IMPULSE RESPONSE 0.4 0.4
0.3 0.3
0.2 0.2
0.1 0.1
0 0
−0.1 −0.1 0 2 4 6 8 10 12 0 2 4 6 8 10 12
TYPE III IMPULSE RESPONSE TYPE IV IMPULSE RESPONSE
0.3 0.3
0.2 0.2
0.1 0.1
0 0
−0.1 −0.1
−0.2 −0.2
−0.3 −0.3
0 2 4 6 8 10 12 0 2 4 6 8 10 12
When h(n) is nonzero for 0 ≤ n ≤ N −1 (the length of the impulse response h(n) is N), then the symmetry of the impulse response can be written as h(n) = h(N − 1 − n) and the anti-symmetry can be written as h(n) = −h(N − 1 − n).
I. Selesnick EL 713 Lecture Notes 8 FOUR TYPES OF LINEAR-PHASE FIR FILTERS
Important note: If the impulse response h(n) is complex-valued, then to have linear-phase the impulse response should be conjugate- symmetric or conjugate-anti-symmetry.
I. Selesnick EL 713 Lecture Notes 9 TYPE I: ODD-LENGTH SYMMETRIC
The frequency response of a length N = 5 FIR Type I filter can be written as follows.
f −jω −2jω −3jω −4ω H (ω) = h0 + h1e + h2e + h1e + h0e (1) −2jω 2jω jω −jω −2jω = e h0e + h1e + h2 + h1e + h0e (2) −2jω 2jω −2jω jω −jω = e h0(e + e ) + h1(e + e ) + h2 (3)
−2jω = e (2h0 cos (2ω) + 2h1 cos (ω) + h2) (4) = A(ω)ejθ(ω) (5) where
θ(ω) = −2ω, A(ω) = 2h0 cos (2ω) + 2h1 cos (ω) + h2.
Note that A(ω) is real-valued and can be both positive and negative. In general, for a Type I FIR filters of length N:
Hf (ω) = A(ω)ejθ(ω)
M−1 X A(ω) = h(M) + 2 h(n) cos ((M − n)ω). n=0 θ(ω) = −Mω N − 1 M = . 2
I. Selesnick EL 713 Lecture Notes 10 TYPE II: EVEN-LENGTH SYMMETRIC
The frequency response of a length N = 4 FIR Type II filter can be written as follows.
f −jω −2jω −3jω H (ω) = h0 + h1e + h1e + h0e (6) − 3 jω 3 jω 1 jω − 1 jω − 3 jω = e 2 h0e 2 + h1e 2 + h1e 2 + h0e 2 (7)
− 3 jω 3 jω − 3 jω 1 jω − 1 jω = e 2 h0(e 2 + e 2 ) + h1(e 2 + e 2 ) (8)
3 − 2 jω 3 1 = e 2h0 cos 2ω + 2h1 cos 2ω (9) = A(ω)ejθ(ω) (10) where 3 θ(ω) = − ω, A(ω) = 2h cos 3ω + 2h cos 1ω. 2 0 2 1 2 In general, for a Type II FIR filters of length N:
Hf (ω) = A(ω)ejθ(ω)
N −1 X2 A(ω) = 2 h(n) cos ((M − n)ω) n=0 θ(ω) = −Mω N − 1 M = . 2
I. Selesnick EL 713 Lecture Notes 11 TYPE III: ODD-LENGTH ANTI-SYMMETRIC
The frequency response of a length N = 5 FIR Type III filter can be written as follows.
f −jω −3jω −4ω H (ω) = h0 + h1e − h1e − h0e (11) −2jω 2jω jω −jω −2jω = e h0e + h1e − h1e − h0e (12) −2jω 2jω −2jω jω −jω = e h0(e − e ) + h1(e − e ) (13) −2jω = e (2jh0 sin (2ω) + 2jh1 sin (ω)) (14) −2jω = e j (2h0 sin (2ω) + 2h1 sin (ω)) (15) −2jω j π = e e 2 (2h0 sin (2ω) + 2h1 sin (ω)) (16) = A(ω)ejθ(ω) (17) where π θ(ω) = −2ω + ,A(ω) = 2h sin (2ω) + 2h sin (ω). 2 0 1 In general, for a Type III FIR filters of length N:
Hf (ω) = A(ω)ejθ(ω)
M−1 X A(ω) = 2 h(n) sin ((M − n)ω) n=0 π θ(ω) = −Mω + 2 N − 1 M = . 2
I. Selesnick EL 713 Lecture Notes 12 TYPE IV: EVEN-LENGTH ANTI-SYMMETRIC
The frequency response of a length N = 4 FIR Type IV filter can be written as follows.
f −jω −2jω −3jω H (ω) = h0 + h1e − h1e − h0e (18) − 3 jω 3 jω 1 jω − 1 jω − 3 jω = e 2 h0e 2 + h1e 2 − h1e 2 − h0e 2 (19)
− 3 jω 3 jω − 3 jω 1 jω − 1 jω = e 2 h0(e 2 − e 2 ) + h1(e 2 − e 2 ) (20)
3 − 2 jω 3 1 = e 2jh0 sin 2ω + 2jh1 sin 2ω (21) 3 − 2 jω 3 1 = e j 2h0 sin 2ω + 2h1 sin 2ω (22) 3 π − 2 jω j 2 3 1 = e e 2h0 sin 2ω + 2h1 sin 2ω (23) = A(ω)ejθ(ω) (24) where 3 π θ(ω) = − ω + ,A(ω) = 2h sin 3ω + 2h sin 1ω. 2 2 0 2 1 2 In general, for a Type IV FIR filters of length N:
Hf (ω) = A(ω) ejθ(ω)
N −1 X2 A(ω) = 2 h(n) sin ((M − n)ω) n=0 π θ(ω) = −Mω + 2 N − 1 M = . 2
I. Selesnick EL 713 Lecture Notes 13 SUMMARY: AMPLITUDE FORMULAS
Type θ(ω) A(ω) M−1 X I −Mω h(M) + 2 h(n) cos ((M − n)ω) n=0 N −1 X2 II −Mω 2 h(n) cos ((M − n)ω) n=0 M−1 π X III −Mω + 2 2 h(n) sin ((M − n)ω) n=0 N 2 −1 π X IV −Mω + 2 2 h(n) sin ((M − n)ω) n=0
N − 1 M = 2
I. Selesnick EL 713 Lecture Notes 14 AMPLITUDE RESPONSE CHARACTERISTICS
To analyze or design linear-phase FIR filters, we need to know the characteristics of the amplitude response A(ω).
Type Properties A(ω) is even about ω = 0 A(ω) = A(−ω) I A(ω) is even about ω = π A(π + ω) = A(π − ω) A(ω) is periodic with 2π A(ω + 2π) = A(ω) A(ω) is even about ω = 0 A(ω) = A(−ω) II A(ω) is odd about ω = π A(π + ω) = −A(π − ω) A(ω) is periodic with 4π A(ω + 4π) = A(ω) A(ω) is odd about ω = 0 A(ω) = −A(−ω) III A(ω) is odd about ω = π A(π + ω) = −A(π − ω) A(ω) is periodic with 2π A(ω + 2π) = A(ω) A(ω) is odd about ω = 0 A(ω) = −A(−ω) IV A(ω) is even about ω = π A(π + ω) = A(π − ω) A(ω) is periodic with 4π A(ω + 4π) = A(ω)
TYPE I A(ω) TYPE II A(ω) 1.2 1
1 0.5 0.8
0.6 0 0.4
0.2 −0.5 0
−0.2 −1 0 0.5 1 1.5 2 0 0.5 1 1.5 2 ω/π ω/π TYPE III A(ω) TYPE IV A(ω) 1.5 2
1 1.5
0.5 1 0 0.5 −0.5
0 −1
−1.5 −0.5 0 0.5 1 1.5 2 0 0.5 1 1.5 2 ω/π ω/π
I. Selesnick EL 713 Lecture Notes 15 EVALUATING THE AMPLITUDE RESPONSE
The frequency response Hf (ω) of an FIR filter can be evaluated at L equally spaced frequencies between 0 and π using the DFT. Consider a causal FIR filter with an impulse response h(n) of length- N, with N ≤ L. Samples of the frequency response of the filter can be written as N−1 2π X −j 2π nk H k = h(n)e L . L n=0 Define the L-point signal {g(n), 0 ≤ n ≤ L − 1} as ( h(n) 0 ≤ n ≤ N − 1 g(n) = 0 N ≤ n ≤ L − 1. Then 2π H k = G(k) = DFT {g(n)} L L where G(k) is the L-point DFT of g(n). Types I and II Suppose the FIR filter h(n) is either a Type I or a Type II FIR filter. Then we have from above
Hf (ω) = A(ω) e−jMω or
A(ω) = Hf (ω) ejMω.
Samples of the real-valued amplitude A(ω) can be obtained from samples of the function Hf (ω) as: 2π 2π jM 2π k Mk A k = H k e L = G(k) · W . L L L
I. Selesnick EL 713 Lecture Notes 16 EVALUATING THE AMPLITUDE RESPONSE (2)
Therefore, the samples of the real-valued amplitude function can be obtained by zero-padding h(n), taking the DFT, and multiplying by the complex exponential. This can be written as:
2π A k = DFT {[h(n), 0 ]}· W Mk. L L L−N L
Types III and IV For Type III and Type IV FIR filters, we have
Hf (ω) = j e−jMω A(ω) or
A(ω) = −j Hf (ω) ejMω.
Therefore, samples of the real-valued amplitude A(ω) can be ob- tained from samples of the function Hf (ω) as: 2π 2π jM 2π k Mk A k = −j H k e L = −j G(k) · W . L L L Therefore, the samples of the real-valued amplitude function can be obtained by zero-padding h(n), taking the DFT, and multiplying by the complex exponential.
2π A k = −j · DFT {[h(n), 0 ]}· W Mk. L L L−N L
I. Selesnick EL 713 Lecture Notes 17 EXAMPLE: EVALUATING THE AMP RESP (TYPE I)
In this example, the filter is a Type I FIR filter of length 7. An accurate plot of A(ω) can be obtained with zero padding.
|H(ω)|=|A(ω)| 1
0.8
0.6
0.4
0.2
0 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 ω/π
A(ω) 1.2
1
0.8
0.6
0.4
0.2
0
−0.2 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 ω/π
The following Matlab code fragment for the plot of A(ω) for a Type I FIR filter. h = [3 4 5 6 5 4 3]/30; N = 7; M = (N-1)/2; L = 512; H = fft([h zeros(1,L-N)]); k = 0:L-1; W = exp(j*2*pi/L); A = H .* W.^(M*k); A = real(A); figure(1) w = [0:L-1]*2*pi/L;
I. Selesnick EL 713 Lecture Notes 18 subplot(2,1,1) plot(w/pi,abs(H)) ylabel(’|H(\omega)| = |A(\omega)|’) xlabel(’\omega/\pi’) subplot(2,1,2) plot(w/pi,A) ylabel(’A(\omega)’) xlabel(’\omega/\pi’) print -deps type1
The command A = real(A) removes the imaginary part which is equal to zero to within computer precision. Without this command, Matlab takes A to be a complex vector and the following plot com- mand will not be right.
Observe the symmetry of A(ω) due to h(n) being real-valued. Be- cause of this symmetry, A(ω) is usually plotted for 0 ≤ ω ≤ π only.
I. Selesnick EL 713 Lecture Notes 19 EXAMPLE: EVALUATING THE AMP RESP (TYPE II)
1
0.8 )| ω 0.6 )| = |A(
ω 0.4 |H( 0.2
0 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 ω/π
1
0.5 )
ω 0 A(
−0.5
−1 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 ω/π
The following Matlab code fragment produces a plot of A(ω) for a Type II FIR filter. h = [3 5 6 7 7 6 5 3]/42; N = 8; M = (N-1)/2; L = 512; H = fft([h zeros(1,L-N)]); k = 0:L-1; W = exp(j*2*pi/L); A = H .* W.^(M*k); A = real(A); figure(1) w = [0:L-1]*2*pi/L; subplot(2,1,1) plot(w/pi,abs(H)) ylabel(’|H(\omega)| = |A(\omega)|’) xlabel(’\omega/\pi’)
I. Selesnick EL 713 Lecture Notes 20 subplot(2,1,2) plot(w/pi,A) ylabel(’A(\omega)’) xlabel(’\omega/\pi’) print -deps type2
The imaginary part of the amplitude is zero. Notice that A(π) = 0. In fact this will always be the case for a Type II FIR filter.
An exercise for the student: Describe how to obtain samples of A(ω) for Type III and Type IV FIR filters. Modify the Matlab code above for these types. Do you notice that A(ω) = 0 always for special values of ω?
I. Selesnick EL 713 Lecture Notes 21 ZERO LOCATIONS OF LINEAR-PHASE FILTERS Sec 4.4.4 in Mitra The zeros of the transfer function H(z) of a linear-phase filter lie in specific configurations. We can write the symmetry condition h(n) = h(N − 1 − n) in the Z domain. Taking the Z-transform of both sides gives H(z) = z−(N−1) H(1/z). (25)
Recall that we are assuming that h(n) is real-valued. If zo is a zero of H(z),
H(zo) = 0, then
∗ H(zo) = 0. (Because the roots of a polynomial with real coefficients exist in complex-conjugate pairs.) Using the symmetry condition (25), it follows that
−(N−1) H(zo) = zo H(1/zo) = 0 and
∗ ∗ −(N−1) ∗ H(zo) = (zo) H(1/zo) = 0 or
∗ H(1/zo) = H(1/zo) = 0.
If zo is a zero of a (real-valued) linear-phase filter, then so are ∗ ∗ zo, 1/zo, 1/zo.
I. Selesnick EL 713 Lecture Notes 22 ZEROS LOCATIONS (2)
It follows that 1. generic zeros of a linear-phase filter exist in sets of 4.
jω 2. zeros on the unit circle (zo = e o ) exist in sets of 2. (z0 6= ±1)
3. zeros on the real line (zo = a) exist in sets of 2. (z0 6= ±1)
4. zeros at 1 and −1 do not imply the existence of zeros at other specific points. Examples of zero sets:
1.5 1 1 0.5 0.5
0 0
−0.5 Imaginary part Imaginary part −0.5 −1
−1.5 −1 −1 0 1 2 −1 −0.5 0 0.5 1 Real part Real part
1 1
0.5 0.5
0 0
Imaginary part −0.5 Imaginary part −0.5
−1 −1 −1 −0.5 0 0.5 1 −1 −0.5 0 0.5 1 Real part Real part
1.5
1
0.5
0
−0.5 Imaginary part
−1
−1.5 −2 −1 0 1 Real part
I. Selesnick EL 713 Lecture Notes 23 ZERO LOCATIONS: AUTOMATIC ZEROS
The frequency response Hf (ω) of a Type II FIR filter always has a zero at ω = π:
h(n) = [h0, h1, h2, h2, h1, h0] −1 −2 −3 −4 −5 H(z) = h0 + h1z + h2z + h2z + h1z + h0z
H(−1) = h0 − h1 + h2 − h2 + h1 − h0 = 0 Hf (π) = H(ejπ) = H(−1) = 0
Hf (π) = 0 always for Type II filters.
Similarly, we can derive the following rules for Type III and Type IV FIR filters.
Hf (0) = Hf (π) = 0 always for Type III filters.
Hf (0) = 0 always for Type IV filters.
The automatic zeros can also be derived using the characteristics of the amplitude response A(ω) seen earlier.
Type automatic zeros I — II ω = π III ω = 0, π IV ω = 0
I. Selesnick EL 713 Lecture Notes 24 ZERO LOCATIONS: EXAMPLES
The Matlab command zplane can be used to plot the zero loca- tions of FIR filters.
TYPE I TYPE II
2 2
1 1
0 0
Imaginary part −1 Imaginary part −1
−2 −2
−1 0 1 2 3 4 5 −5 −4 −3 −2 −1 0 1 Real part Real part TYPE III TYPE IV
2 2
1 1
0 0
Imaginary part −1 Imaginary part −1
−2 −2
−1 0 1 2 3 4 5 −1 0 1 2 3 4 5 Real part Real part
Note that the zero locations satisfy the properties noted previously.
I. Selesnick EL 713 Lecture Notes 25 DESIGN OF FIR FILTERS BY DFT-BASED INTERPOLATION
One approach to the design of FIR filters is to ask that A(ω) pass through a specified set of values. If the number of specified inter- polation points is the same as the number of filter parameters, then the filter is totally determined by the interpolation conditions, and the filter can be found by solving a system of linear equations. When the interpolation points are equally spaced between 0 and 2π, then this interpolation problem can be solved very efficiently using the DFT. To derive the DFT solution to the interpolation problem, recall the formula relating the samples of the frequency response to the DFT. In the case we are interested here, the number of samples is to be the same as the length of the filter (L = N). N−1 2π X −j 2π nk H k = h(n)e N N n=0
= DFTN {h(n)}.
Types I and II Recall the relation between A(ω) and Hf (ω) for a Type I and II filter, to obtain 2π 2π jM 2π k A k = H k · e N N N Mk = DFTN {h(n)}· WN Now we can related the N-point DFT of h(n) to the samples of A(ω): 2π DFT {h(n)} = A k · W −Mk. N N N
I. Selesnick EL 713 Lecture Notes 26 Finally, we can solve for the filter coefficients h(n).
2π h(n) = DFT−1 A k · W −Mk . N N N