Discrete Fourier Transform Valentina Hubeika, Jan Černocký DCGM FIT BUT Brno, {ihubeika,cernocky}@fit.vutbr.cz
Diskrete Fourier transform (DFT) We have just one problem with DFS that needs to be solved. Infinite length of signal and finite length of computed spectrum. DFT transforms a sequence of length N to other sequence of length N we will see that it is a transform of one period of the input signal to one period in DFS. The procedure is the following:. periodize a sequence x[n] of length N : x[n] = x[ mod N (n)]. N. find DFS coefficients: X[k] = n= x[n]e j π N kn. Note, only one period of periodic signal x[ mod N (n)] is taken, therefore, we can work just with original sequence x[n]. Step. is taken to fulfill requirements for DFS computing. 3. resulting sequence is windowed again to the length N: X[k] = R N [k] N n= x[n]e j π N kn
Usually we find this formula with no windowing function as computing only through one period is assumed, X[k] for k = [, N ]: X[k] = N n= x[n]e j π N kn X[k] is a projection/image of DFT, denoted as x[n] DFT X[k]. Inverse DFT for samples n = [, N ] is obtained in the same manner ( periodization of DFT spectrum, inverse DFS application, windowing of the resulting periodic signal) : x[n] = N N k= X[k]e +j π N kn, we denote X[k] DFT x[n] 3
Frequency axis in DFT N samples of DFT are placed from approaching sampling frequency: sampling frequency is N. we have N samples placed from to N. thus for samples X[k] holds: normalized frequency k N to N N. normalized circle frequency π k to πn N N regular frequency k N F s to N N F s circle frequency k N πf s to N N πf s
Example : N = 6, shifted square signal of length 8, F s = Hz..5 5 5 8 6 5 5 5 5 5
8 norm. f 8 f 6 6...6.8 3 x 8 norm. omega 8 omega 6 6 6.5.5.5 x 5 6
Example : One period of a harmonic signal, N = 6, F s = Hz, ω = π 6 rad.5.5 5 5 8 6 5 5.5.5 5 5 7
8 norm. f 8 f 6 6...6.8 3 x 8 norm. omega 8 omega 6 6 6.5.5.5 x 5 8
Properties of DFT Image of a real sequence similarly to FS: X[k] = X [N k] X[] would be complex conjugate to X[N], but X[N] does not exist. Recall that according to DFS definition, X[] is a sum of discrete samples, that is a direct component. If N is even, then: X [ N ] = X [ N N is complex conjugate to itself, thus it must be real. Ilustration: see previous examples. ] = X [ N ]. 9
Linearity x [n] DFT X [k] x [n] DFT X [k] ax [n] + bx [n] DFT ax [k] + bx [k] Image of a circulary shifted sequence x[n] DFT X[k] R N x[ mod N (n m)] DFT X[k]e j π N mk
.5.5 5 5 8 6 5 5.5.5 5 5 8 6 5 5 5 5 5 5
Image of circular convolution x [n] DFT X [k] x [n] DFT X [k] x [n] N x [n] DFT X [k]x [k] Similarly as for regular FT convolution of two signals corresponded to multiplication of their spectra in frequency, the DFT image of a circular convolution is a product of DFT coefficients of the convoluted signals.
.5.5 3 3 3.5.5 3.5.5 3.5.5 3.5.5 3 3 3 3.5.5 3 3
Fast Fourier transform FFT Computing of DFT according to: X[k] = N n= x[n]e j π N kn requires N operations (multiplication or addition) with complex numbers. Cooley and Tukey invented an efficient algorithm for DFT and its inverse with N = k, where k is an integer: Fast Fourier transform FFT. The number of operations becomes only N log N. FFT recursively breaks the transform into two N/ transforms processing a pair of samples producing a pair of coefficients in each step. Example: pro N =, N = MOPS, N log N = kops FFT produces the same output as DFT!
Computating FS and FT (with continuous time) using DFT We are interested how to compute a spectral representation (coefficients of FS or FT) just using DFT. first let us summarize what we compute using DFT: the signal is sampled, thus spectrum is periodic (eventhough we compute only one period of spectrum with N samples (, π, F s, πf s, according to the type of frequency). signal is periodic (by N samples) (eventhough we consider only one period for computating of DFT), spectrum is thus sampled (discrete). The step in spectrum is N, π N, F s N, πf s N according to the type of frequency. signal is windowed the spectrum of the window occurs also in DFT image, x(t)w(t) X(jω) W(jω). 5
Computation of coefficients FS using DFT To remind, for a continuous-time signal with period T, FS coefficients are: c k = T T x(t)e jkω t dt, If such signal is sampled with sampling period T, and T then contains N samples, we can aproximate the integral using: c k NT N n= π jk x(nt)e NT nt T = T NT N n= x(nt)e jk π N n = N N n= x[n]e jkn π N. This definition resembles the DFT formula with the only difference that we have to divide the c k by the number of samples N: c k = X[k] N. 6
The equation can be used only when the following restrictions are satisfied:. we can compute only coefficients c k for k < N one). (second half is mirrored to the first. sampling theorem must be satisfied: last non-zero coefficient of analog signal is for k max < N, otherwise aliasing ocures. We must to realize that N now corresponds to the sampling frequency, so the above equation is equivalent to: ω max < Ω s. 3. N samples must fit into exactly one period of the signal. When more periods m, we need to make a small modification: c k = S[mk] N 7
Example : signal with continuous time x(t) = cos(5πt + π/) sampled at khz. Compute coefficients of FS using DFT. Period T = π 5π =.6. Number of samples for computation is T T =.6/. = 6. Theoretic values of the coefficients are c = 5e jπ/, c = 5e jπ/ 5 5...6.8....6 8 6 5 5.5.5 5 5 8
Example : signal with continuous time x(t) = cos(5πt) sampled at khz. Compute coefficients of FS using DFT. We don t know the period of the signal, we can choose N = 6. Theoretic values of coefficients are c = 5, c = 5 5 5...6.8....6 8 6 5 5 5 5 9
Example 3: signal with continuous time: periodic sequence of square impulses with D =, ϑ = 3 ms, T = 6 ms, sampled at khz. Compute coefficients of FS using DFT. Theoretic values of coefficients are c k = Dϑ T sinc( ϑ kω )..5...3..5.6 3 3 5 6 3 5 6
Computation of spectral function using DFT again let s remind X(jω) = + x(t)e jωt dt We will able to compute only FT of signal which is restricted from to T : if its is not, we cannot do anything. if it is, but elsewhere for example from t start to t start + T we will move it to [, T ], but we will remember it finally, just small fix of phase will be needed. If such signal is sampled with sampling period T, we get N samples. Integral can be aproximated, but only for some frequencies - that are multiples of Nth portion of the sampling frequency Ω s = π T : k Ω s N. Then: X(jk Ω N s N ) n= x(nt)e jk Ω s N nt T = T N n= π/t jk x(nt)e N nt = T N n= x[n]e jkn π N.
We again see the definition of DFT in the derived equation so for circular frequencies k Ω s N we can write: Again some restrictions: valid only for k < N. X(jk Ω s N ) = TX[k] sampling theorem must be satisfied: the maximum frequency ω max in the signal spectrum must be ω max < Ω s otherwise aliasing occurs. When we have a signal with ω max = (square,... ) we should use Ω s the highest possible so aliasing does not hurt.
We compute values for some certain frequencies, but we are interested in all values of the spectral function. We must interpolate, or use zero-padding getting more samples in the spectrum. the phase need to be fixed if the signal s period was pushed to fit the interval [, T ]: X(jk Ω s N ) X(jkΩ s Ωs N )e jk N t start 3
Example: square impuls s D =, ϑ = 3 ms, sampled at khz. Theoretic spectral function is X(jω) = Dϑsinc( ϑ ω)..5.3.....3.5...3..5.6.5...3..5.6
spectral function computed for N = 6 3 5 5 5 5 5 5 3 3 3 5 5 5 3 5
zero padded and spectral function computed for N = 5.5 3 5 6 3 5 5 5 5 5 5 6
good frequency axis (ω), scaling (multiplied by T) and corrected phase:.3.5..5..5 5 5 5 3 3 3 5 5 5 3 7