Discrete Fourier Transform (DFT) Recall the DTFT: X(ω) = ∞ X x(n)e−jωn. n=−∞ DTFT is not suitable for DSP applications because • In DSP, we are able to compute the spectrum only at specific discrete values of ω, • Any signal in any DSP application can be measured only in a finite number of points. A finite signal measured at N points: n < 0, 0, y(n), 0 ≤ n ≤ (N − 1), x(n) = 0, n ≥ N, where y(n) are the measurements taken at N points. EE 524, Fall 2004, # 5 1 Sample the spectrum X(ω) in frequency so that X(k) = X(k∆ω), X(k) = N −1 X ∆ω = −j2π kn N x(n)e 2π N =⇒ DFT. n=0 The inverse DFT is given by: N −1 kn 1 X x(n) = X(k)ej2π N . N k=0 1 x(n) = N = N −1 X (N −1 X k=0 m=0 N −1 X ( x(m) m=0 | EE 524, Fall 2004, # 5 ) −j2π km N x(m)e 1 N N −1 X −j2π e j2π kn N e k(m−n) N ) = x(n). k=0 {z δ(m−n) } 2 The DFT pair: X(k) = N −1 X kn x(n)e−j2π N analysis n=0 x(n) = N −1 1 X j2π kn X(k)e N N synthesis. k=0 Alternative formulation: X(k) = N −1 X x(n)W kn 2π ←− W = e−j N n=0 x(n) = N −1 1 X X(k)W −kn. N k=0 EE 524, Fall 2004, # 5 3 EE 524, Fall 2004, # 5 4 Periodicity of DFT Spectrum X(k + N ) = N −1 X −j2π x(n)e (k+N )n N n=0 N −1 X = ! −j2π kn N x(n)e e−j2πn n=0 = X(k)e−j2πn = X(k) =⇒ the DFT spectrum is periodic with period N (which is expected, since the DTFT spectrum is periodic as well, but with period 2π). Example: DFT of a rectangular pulse: x(n) = X(k) = 1, 0 ≤ n ≤ (N − 1), 0, otherwise. N −1 X kn e−j2π N = N δ(k) =⇒ n=0 the rectangular pulse is “interpreted” by the DFT as a spectral line at frequency ω = 0. EE 524, Fall 2004, # 5 5 DFT and DTFT of a rectangular pulse (N=5) EE 524, Fall 2004, # 5 6 Zero Padding What happens with the DFT of this rectangular pulse if we increase N by zero padding: {y(n)} = {x(0), . . . , x(M − 1), 0, . . . , 0} }, | 0,{z N −M positions where x(0) = · · · = x(M − 1) = 1. Hence, DFT is Y (k) = N −1 X −j2π kn N y(n)e = M −1 X n=0 = EE 524, Fall 2004, # 5 sin(π kM N ) sin(π Nk ) −j2π kn N y(n)e n=0 −jπ e k(M −1) N . 7 DFT and DTFT of a Rectangular Pulse with Zero Padding (N = 10, M = 5) Remarks: • Zero padding of analyzed sequence “approximating” its DTFT better, results in • Zero padding cannot improve the resolution of spectral components, because the resolution is “proportional” to 1/M rather than 1/N , • Zero padding is very important for fast DFT implementation (FFT). EE 524, Fall 2004, # 5 8 Matrix Formulation of DFT Introduce the N × 1 vectors x(0) x(1) x= .. x(N − 1) , X(0) X(1) . X= .. X(N − 1) and the N × N matrix W= 0 0 0 W W W W0 W1 W2 W0 W2 W4 .. .. .. W 0 W N −1 W 2(N −1) 0 ··· W · · · W N −1 · · · W 2(N −1) .. .. (N −1)2 ··· W . DFT in a matrix form: X = Wx. Result: Inverse DFT is given by x= EE 524, Fall 2004, # 5 1 H W X, N 9 which follows easily by checking W H W = WW H = N I, where I denotes the identity matrix. Hermitian transpose: xH = (xT )∗ = [x(1)∗, x(2)∗, . . . , x(N )∗]. Also, “∗” denotes complex conjugation. Frequency Interval/Resolution: DFT’s frequency resolution Fres ∼ 1 NT [Hz] and covered frequency interval ∆F = N ∆Fres 1 = = Fs T [Hz]. Frequency resolution is determined only by the length of the observation interval, whereas the frequency interval is determined by the length of sampling interval. Thus • Increase sampling rate =⇒ expand frequency interval, • Increase observation time =⇒ improve frequency resolution. Question: Does zero padding alter the frequency resolution? EE 524, Fall 2004, # 5 10 Answer: No, because resolution is determined by the length of observation interval, and zero padding does not increase this length. Example (DFT Resolution): Two complex exponentials with two close frequencies F1 = 10 Hz and F2 = 12 Hz sampled with the sampling interval T = 0.02 seconds. Consider various data lengths N = 10, 15, 30, 100 with zero padding to 512 points. DFT with N = 10 and zero padding to 512 points. Not resolved: F2 − F1 = 2 Hz < 1/(N T ) = 5 Hz. EE 524, Fall 2004, # 5 11 DFT with N = 15 and zero padding to 512 points. Not resolved: F2 − F1 = 2 Hz < 1/(N T ) ≈ 3.3 Hz. DFT with N = 30 and zero padding to 512 points. Resolved: F2 − F1 = 2 Hz > 1/(N T ) ≈ 1.7 Hz. EE 524, Fall 2004, # 5 12 DFT with N = 100 and zero padding to 512 points. Resolved: F2 − F1 = 2 Hz > 1/(N T ) = 0.5 Hz. EE 524, Fall 2004, # 5 13 DFT Interpretation Using Discrete Fourier Series Construct a periodic sequence by periodic repetition of x(n) every N samples: {e x(n)} = {. . . , x(0), . . . , x(N − 1), x(0), . . . , x(N − 1), . . .} | {z } | {z } {x(n)} {x(n)} The discrete version of the Fourier Series can be written as x e(n) = X j2π kn N Xk e k 1 X e 1 X e j2π kn = X(k)e N = X(k)W −kn, N N k k e where X(k) = N Xk . Note that, for integer values of m, we have W −kn j2π kn N =e j2π =e (k+mN )n N = W −(k+mN )n. As a result, the summation in the Discrete Fourier Series (DFS) should contain only N terms: N −1 1 X e j2π kn x e(n) = X(k)e N N DFS. k=0 EE 524, Fall 2004, # 5 14 Inverse DFS The DFS coefficients are given by e X(k) = N −1 X kn x e(n)e−j2π N inverse DFS. n=0 Proof. N −1 X −j2π kn N x e(n)e n=0 N −1 N −1 X 1 X e j2π pn −j2π kn N N X(p)e = e N n=0 p=0 N −1 X = ( e X(p) p=0 1 N N −1 X j2π e (p−k)n N ) e = X(k). n=0 | {z δ(p−k) } 2 The DFS coefficients are given by e X(k) = N −1 X kn x e(n)e−j2π N analysis, n=0 x e(n) = N −1 1 X e j2π kn X(k)e N N synthesis. k=0 EE 524, Fall 2004, # 5 15 • DFS and DFT pairs are identical, except that − DFT is applied to finite sequence x(n), − DFS is applied to periodic sequence x e(n). • Conventional (continuous-time) FS vs. DFS − CFS represents a continuous periodic signal using an infinite number of complex exponentials, whereas − DFS represents a discrete periodic signal using a finite number of complex exponentials. EE 524, Fall 2004, # 5 16 DFT: Properties Linearity Circular shift of a sequence: if X(k) = DFT {x(n)} then km X(k)e−j2π N = DFT {x((n − m) mod N )} Also if x(n) = DFT −1{X(k)} then km x((n − m) mod N ) = DFT −1{X(k)e−j2π N } where the operation mod N denotes the periodic extension x e(n) of the signal x(n): x e(n) = x(n mod N ). EE 524, Fall 2004, # 5 17 DFT: Circular Shift N −1 X x((n − m)modN )W kn n=0 = W km N −1 X x((n − m)modN )W k(n−m) n=0 EE 524, Fall 2004, # 5 18 = W km N −1 X x((n − m)modN )W k(n−m)modN n=0 = W kmX(k), where we use the facts that W k(lmodN ) = W kl and that the order of summation in DFT does not change its result. Similarly, if X(k) = DFT {x(n)}, then j2π mn N X((k − m)modN ) = DFT {x(n)e }. DFT: Parseval’s Theorem N −1 X x(n)y ∗(n) = n=0 N −1 1 X X(k)Y∗(k) N k=0 Using the matrix formulation of the DFT, we obtain yH x = = EE 524, Fall 2004, # 5 H 1 H 1 H W Y W Y N N 1 H 1 H H Y W W } X = Y X. | {z N2 N NI 19 DFT: Circular Convolution If X(k) = DFT {x(n)} and Y (k) = DFT {y(n)}, then X(k)Y (k) = DFT {{x(n)} ~ {y(n)}} Here, ~ stands for circular convolution defined by {x(n)} ~ {y(n)} = N −1 X x(m)y((n − m) mod N ). m=0 DFT {{x(n)} ~ {y(n)}} N −1 h i X PN −1 kn = x(m)y((n − m) mod N ) W m=0 | {z } n=0 {x(n)}~{y(n)} = N −1 h X PN −1 n=0 m=0 | = Y (k) N −1 X |m=0 EE 524, Fall 2004, # 5 i y((n − m) mod N )W kn x(m) {z } Y (k)W km x(m)W km = X(k)Y (k). {z X(k) } 20