Professional Documents
Culture Documents
The Discrete Fourier Transform (DFT) :: ECE-600 Phil Schniter January 31, 2011
The Discrete Fourier Transform (DFT) :: ECE-600 Phil Schniter January 31, 2011
n=0
x[n]e
j
2
N
kn
, k = 0 . . . N1
and the corresponding IDFT is
x[n] =
1
N
N1
k=0
X[k]e
j
2
N
kn
, n = 0 . . . N1.
Note:
the signal has nite duration N,
there are only N DFT coecients.
2
ECE-600 Phil Schniter January 31, 2011
DFT Interpretation # 1 sampled DTFT:
Say signal x[n] has duration N. Then
X(e
j
) =
n=
x[n]e
jn
=
N1
n=0
x[n]e
jn
.
Meanwhile,
X[k] =
N1
n=0
x[n]e
j
2
N
kn
= X(e
j
)
=
2
N
k
for k = 0 . . . N1.
Thus, the DFT returns
2
N
-spaced samples of the DTFT.
Example for N = 8:
0 2 4 6
0
0.2
0.4
0.6
0.8
1
1.2
1.4
1.6
1.8
2
0 2 4 6
0
1
2
3
4
5
6
7
8
n
x
[
n
]
X[k]
X(e
j
)
3
ECE-600 Phil Schniter January 31, 2011
The DFT and zero-padding:
Again, say x[n] has duration N.
The M-length zero-padded signal
x[n]
_
x[n] n = 0 . . . N1
0 n = N . . . M1
has the M-point DFT
X[k] =
M1
n=0
x[n]e
j
2
M
kn
=
N1
n=0
x[n]e
j
2
M
kn
= X(e
j
)
[
=
2
M
k
.
Thus, zero-padding increases the rate at which the DFT
samples the DTFT!
0 1 2 3 4 5 6 7
0
1
2
0 1 2 3 4 5 6
0
2
4
6
8
0 5 10 15 20 25 30
0
1
2
0 1 2 3 4 5 6
0
2
4
6
8
n
n
x
[
n
]
x
[
n
]
[
X
(
e
j
)
[
[
X
(
e
j
)
[
4
ECE-600 Phil Schniter January 31, 2011
DTFT sampling and time-domain aliasing:
Previously we saw that, when the time-domain sampling
rate (in samp/sec) is too small with respect to the signal
bandwidth (in Hz), frequency-domain aliasing results.
Wide bandwidth quick time variations.
Now we will see that, when the frequency-domain
sampling rate (in samp/Hz) is too slow with respect to
the signal duration (in sec), time-domain aliasing results.
Long duration quick frequency variations.
Say were given Y [k] X(e
j
)
[
=
2
N
k
for k = 0 . . . N1,
where X(e
j
)
DTFT
x[n] for some x[n] of generic length.
1. If x[n] was length-N, then
Y [k] = X[k] since the DFT
2
N
-samples the DTFT.
In this case, we can recover x[n] from Y [k] via
x[n]
N1
n=0
= T
1
N-DFT
_
Y [k]
N1
k=0
_
.
2. If x[n] was not length-N, then can we still recover
x[n]
N1
n=0
from the N DTFT samples Y [k]
N1
n=0
?
5
ECE-600 Phil Schniter January 31, 2011
An IDFT of Y [k]
N1
n=0
yields
y[n]
1
N
N1
k=0
Y [k]e
j
2
N
kn
, n = 0 . . . N1
=
1
N
N1
k=0
X(e
j
2
N
k
)e
j
2
N
kn
=
1
N
N1
k=0
_
m=
x[m]e
j
2
N
km
_
e
j
2
N
kn
=
m=
x[m]
1
N
N1
k=0
e
j
2
N
k(mn)
. .
[nm
N
] =
_
1 if nm = . . . 0, N, 2N . . .
0 else
=
q=
x[n qN], n = 0 . . . N1.
n n
n
n
x[n N]
x[n]
x[n + N]
y[n]
.
.
.
.
.
.
0 N1
(N = 3)
6
ECE-600 Phil Schniter January 31, 2011
DFT Interpretation #2 discrete-time FS:
Say x(t) is periodic with P-second period, and x(t) contains
only the rst period of x(t). Then, from Fourier series,
x(t) =
1
P
k=
PX
k
e
j
2
P
kt
, t [0, P)
PX
k
=
_
P
0
x(t)e
j
2
P
kt
dt = X
c
(j)
=
2
P
k
Say x[n] is periodic with N-sample period, and x[n] contains
only the rst period of x[n]. Then, from the DFT,
x[n] =
1
N
N1
k=0
X[k]e
j
2
N
kn
, n = 0 . . . N1
X[k] =
N1
n=0
x[n]e
j
2
N
kn
= X(e
j
)
=
2
N
k
Thus, one could interpret the DFT coecients X[k]
N1
k=0
as
the coecients of a discrete-time Fourier series.
. . . . . .
x[n]
x[n]
n
n
7
ECE-600 Phil Schniter January 31, 2011
DFT of sampled periodic signals:
Now say that x[n] is sampled from x(t) on the previous page
using N samples per period, i.e., x[n] = x(n
P
N
). Then
x[n] = x(n
P
N
) =
k=
X
k
e
j
2
P
kn
P
N
(from FS expansion)
=
1
N
k=
NX
k
e
j
2
N
kn
=
1
N
N1
m=0
_
l=
NX
m+lN
_
e
j
2
N
mn
via k = m + lN for m = 0 . . . N1 and l Z.
This implies that the DFT coecients are related to the
CT-FS coecients as follows:
X[m] = N
l=
X
m+lN
, for m = 0 . . . N1.
Under what conditions do the CT-FS coecients lead to
aliasing?
When X
k
,= 0 for k N (i.e., bandwidth too large).
8
ECE-600 Phil Schniter January 31, 2011
Circular Convolution:
What results from multiplying two N-point DFTs?
X[k]W[k] =
N1
m=0
x[m]e
j
2
N
mk
N1
l=0
w[l]e
j
2
N
lk
=
N1
m=0
x[m]
N1
l=0
w[l]e
j
2
N
(m+l)k
.
Using the substitution
l = n m
N
= n m + qN for some q Z
we get
X[k]W[k] =
N1
m=0
x[m]
N1
n=0
w[n m
N
] e
j
2
N
(m+nm+qN)k
. .
e
j
2
N
nk
=
N1
n=0
_
N1
m=0
x[m]w[n m
N
]
_
e
j
2
N
nk
N-DFT
N1
m=0
x[m]w[n m
N
] x[n] N w[n]
known as N-circular convolution.
9
ECE-600 Phil Schniter January 31, 2011
Circular Convolution (cont.):
Linear convolution: y[n] =
m=
x[m]w[n m]:
ip and slide (linearly). . .
=
N-circular convolution: y[n] =
N1
m=0
x[m]w[n m
N
]:
ip and slide (cyclically). . .
N
0
0 N1
N1
=
=
or cyclically extend, ip, and slide (linearly). . .
y[n] =
m=
x[m
N
]w[n m]
(Assume nite-length w[m] is zero-extended in last equation.)
10
ECE-600 Phil Schniter January 31, 2011
Circular Convolution Examples:
1. Consider [1, 2, 3] N [2, 1, 1] for N = 3:
1 2 3 1 2 3 1 2 3 out:
1 1 2 1
1 1 2 6
1 1 2 5
1 1 2 1
1 1 2 6
1 1 2 5
.
.
.
.
.
.
2. Now consider [1, 2, 3] N [2, 1, 1] for N = 5,
or, equivalently, [1, 2, 3, 0, 0] N [2, 1, 1, 0, 0] for N = 5:
1 2 3 0 0 1 2 3 0 0 out:
0 0 1 1 2 2
0 0 1 1 2 3
0 0 1 1 2 5
0 0 1 1 2 1
0 0 1 1 2 3
.
.
.
.
.
.
11
ECE-600 Phil Schniter January 31, 2011
The DFT important properties:
Here, x[n]
N-DFT
X[k], w[n]
N-DFT
W[k], and n, k = 0 . . . N1.
1. Linearity:
x[n] + w[n]
N-DFT
X[k] + W[k]
2. Conjugate symmetry:
x
[n] = x[n
N
] X[k] R
x[n] R X
[k] = X[k
N
]
3. Shift/modulation:
x[n d
N
]
N-DFT
e
j
2
N
kd
X[k], d Z
e
j
2
N
nd
x[n]
N-DFT
X[k d
N
], d Z
4. Reversal:
x[n
N
]
N-DFT
X[k
N
]
5. Multiplication/convolution:
x[n]w[n]
N-DFT
1
N
N1
l=0
X[l]W[k l
N
]
N1
m=0
x[m]w[n m
N
]
N-DFT
X[k]W[k]
6. Energy conservation (Parsevals theorem):
N1
n=0
[x[n][
2
=
1
N
N1
k=0
[X[k][
2
12
ECE-600 Phil Schniter January 31, 2011
Working with modulo indices:
Many DFT properties involve modulo-N indices!
Main idea: m
N
= m + qN for integer q (in fact
q =
m
N
, but the exact value will not matter). Recall
circular convolution example (p. ??). Heres another. . .
Proof of x[n
N
]
N-DFT
X[k
N
]:
x[n
N
]
N-DFT
N1
n=0
x[ n
N
. .
n + qN m
]e
j
2
N
nk
for integer q
=
N1
m=0
x[m]e
j
2
N
(qNm)k
same sum!
=
N1
m=0
x[m]e
j
2
N
m(k)
Cant write X[k] because DFT is only dened for
k = 0 . . . N1! Instead, k
N
= k + rN for r Z:
=
N1
m=0
x[m]e
j
2
N
m(k
N
rN)
for integer r
= X[k
N
]
Example: n : 5 4 3 2 1 0 1 2 3 4 5
x[n] : 0 0 0 0 0 a b c d e 0
x[n] : 0 e d c b a 0 0 0 0 0
x[n
5
] : a e d c b a e d c b a
13
ECE-600 Phil Schniter January 31, 2011
Spectral Analysis:
t = nT
x(t)
x[n] y[n]
Y [k]
1
2T
-Hz
LPF
M-length
window w[n]
N-length
DFT
Goal: Determine frequency components in x(t).
Method: Sample, buer, window, transform to freq.
Questions: How to choose M, w[n], and N?
How to interpret DFT outputs Y [k]?
Recall key relationships:
X(e
j
) =
1
T
X
c
(j
T
), [, ) (no aliasing)
Y (e
j
) =
1
2
_
X(e
j
)W(e
j()
)d (y[n] = x[n]w[n])
Y [k] = Y (e
j
2
N
k
) (if N M)
Example:
3 2 1 0 1 2 3
25
20
15
10
5
0
5
10
15
20
25
complex sinusoid at
0
=0.32, M=16, N=32
DTFT
DFT
d
B
m
a
g
n
i
t
u
d
e
14
ECE-600 Phil Schniter January 31, 2011
Spectral Analysis (cont.):
Suppose our signal is a sum of L complex sinusoids:
x(t) =
L
l=1
a
l
e
j
l
t
for [
l
[ <
T
.
Then, using the relationships from the previous page,
X
c
(j) = 2
L
l=1
a
l
(
l
)
X(e
j
) =
2
T
L
l=1
a
l
(
T
l
) for [, )
Y (e
j
) =
1
T
_
l=1
a
l
(
T
l
)W(e
j()
)d
=
L
l=1
a
l
_
/T
/T
(
l
)W(e
j(T)
)d via =
T
=
L
l=1
a
l
W(e
j(
l
T)
)
. . . a sum of scaled and shifted window-DTFTs! Finally,
Y [k] =
L
l=1
a
l
W(e
j(
2
N
k
l
T)
)
So we expect a DFT peak near k =
l
TN
2
for each l = 1...L.
15
ECE-600 Phil Schniter January 31, 2011
Eects of nite data-length:
When L > 1, the DFT peaks may not be where we expect!
There are two main reasons for this:
1. Leakage: The energy at
l
=
l
T gets spread over all
[, ] through the windows sidelobes.
Weak sinusoids
get buried!
3 2 1 0 1 2 3
20
0
20
complex sinusoid: 1=2, a1 = 1, M=16
d
B
3 2 1 0 1 2 3
40
20
0
complex sinusoid: 2=2, a2 = 0.05, M=16
d
B
3 2 1 0 1 2 3
20
0
20
summed signal, M=16
d
B
peak sidelobes
@ 13dB
resolution
1.2
2
M
where resolution means 6 dB bandwidth and
approximates the minimum spacing between recognizable
sinusoids (of equal amplitude).
17
ECE-600 Phil Schniter January 31, 2011
Bartlett window:
0 5 10 15 20 25 30
0
0.2
0.4
0.6
0.8
1
Bartlett window, M=32
3 2 1 0 1 2 3
100
80
60
40
20
0
peak sidelobe=26dB
6dB width=1.8x2/M
DTFT magnitude
d
B
peak sidelobes
@ 26dB
resolution
1.8
2
M
Triangular window:
0 5 10 15 20 25 30
0
0.2
0.4
0.6
0.8
1
triangular window, M=32
3 2 1 0 1 2 3
100
80
60
40
20
0
peak sidelobe=27dB
6dB width=1.8x2/M
DTFT magnitude
d
B
improved: edge
points are not
zero-valued!
peak sidelobes
@ 27dB
resolution
1.8
2
M
18
ECE-600 Phil Schniter January 31, 2011
Hann window:
0 5 10 15 20 25 30
0
0.2
0.4
0.6
0.8
1
Hann window, M=32
3 2 1 0 1 2 3
100
80
60
40
20
0
peak sidelobe=31dB
6dB width=2.1x2/M
DTFT magnitude
d
B
w[n] =
1
2
1
2
cos(
2
M
n)
peak sidelobes
@ 31dB
resolution
2.1
2
M
Hamming window:
0 5 10 15 20 25 30
0
0.2
0.4
0.6
0.8
1
Hamming window, M=32
3 2 1 0 1 2 3
100
80
60
40
20
0
peak sidelobe=42dB
6dB width=1.9x2/M
DTFT magnitude
d
B
w[n] = 0.538
0.462 cos(
2
M
n)
peak sidelobes
@ 42dB
resolution
1.9
2
M
19
ECE-600 Phil Schniter January 31, 2011
Blackman window:
0 5 10 15 20 25 30
0
0.2
0.4
0.6
0.8
1
Blackman window, M=32
3 2 1 0 1 2 3
100
80
60
40
20
0
peak sidelobe=58dB
6dB width=2.4x2/M
DTFT magnitude
d
B
w[n] = 0.42
1
2
cos(
2
M
n) +
0.08 cos(
4
M
n)
peak sidelobes
@ 58dB
resolution
2.4
2
M
Blackman-harris window:
0 5 10 15 20 25 30
0
0.2
0.4
0.6
0.8
1
Blackmanharris window, M=32
3 2 1 0 1 2 3
100
80
60
40
20
0
peak sidelobe=92dB
6dB width=2.7x2/M
DTFT magnitude
d
B
optimized 4-term
peak sidelobes
@ 92dB
resolution
2.7
2
M
20
ECE-600 Phil Schniter January 31, 2011
Kaiser window:
Has adjustable parameter . For peak sidelobe level S
dB
,
=
_
_
0 S
dB
13.26
0.76609(S
dB
13.26)
0.4
+ 0.09834(S
dB
13.26) 13.26 < S
dB
60
0.12438(S
dB
+ 6.3) 60 < S
dB
120
For example, S
dB
= 57 gives = 8.03 and, when M = 32,
0 5 10 15 20 25 30
0
0.2
0.4
0.6
0.8
1
Kaiser window, beta=8.03, M=32
3 2 1 0 1 2 3
100
80
60
40
20
0
peak sidelobe=58dB
6dB width=2.3x2/M
DTFT magnitude
d
B
based on modied
Bessel function
peak sidelobes
@ 58dB
resolution
2.3
2
M
which is very similar (and slightly better) than Blackman.
The approximate tradeo between peak sidelobe level S
dB
and 6dB mainlobe width
0.029(29 S
dB
0.003 S
2
dB
)
2
M
.
21
ECE-600 Phil Schniter January 31, 2011
Spectral analysis example:
Real sines at 30 Hz & 32 Hz,
1
T
= 120 Hz. ( =
22
120
)
Recall: M-length data, N-length DFT.
Rectangular window: resolution
1.22
M
( M > 72).
0 1 2 3
0
0.2
0.4
0.6
0.8
1
M=80, N=80
D
F
T
m
a
g
n
i
t
u
d
e
0 1 2 3
0
0.2
0.4
0.6
0.8
1
M=80, N=160
0 1 2 3
0
0.2
0.4
0.6
0.8
1
M=80, N=2048
0 1 2 3
0
0.2
0.4
0.6
0.8
1
M=70, N=2048
In general:
Need DFT length N 2M, but prefer N 2M.
22
ECE-600 Phil Schniter January 31, 2011
The fast Fourier transform (FFT):
A family of algorithms to quickly compute the DFT.
Recall that the N-DFT
X[k] =
N1
n=0
x[n]e
j
2
N
kn
consumes N (complex-valued) multiplications per output,
and thus N
2
multiplications total.
We will describe the so-called radix-2 decimate-in-time
FFT, which works when N is power-of-two, and consumes
approximately
N
2
log
2
N multiplications.
0 200 400 600 800 1000
0
1
2
3
4
5
6
7
8
9
10
x 10
5
N
n
u
m
b
e
r
o
f
m
u
l
t
i
p
l
i
e
s
DFT
FFT
When N is large, this is much cheaper than the DFT!
23
ECE-600 Phil Schniter January 31, 2011
The radix-2 FFT:
Notice that
X[k] =
N1
n=0
x[n]W
kn
N
for W
kn
N
e
j
2
N
kn
=
n even
x[n]W
kn
N
+
n odd
x[n]W
kn
N
=
N/21
m=0
x[2m]W
k2m
N
+
N/21
m=0
x[2m + 1]W
k(2m+1)
N
Because W
2q
N
= W
q
N/2
and W
q+p
N
= W
q
N
W
p
N
, we can write
X[k] =
N/21
m=0
x[2m]W
km
N/2
. .
G[k]
+W
k
N
N/21
m=0
x[2m + 1]W
km
N/2
. .
H[k]
Note: G[k] is an
N
2
-DFT of the even samples, and H[k] is an
N
2
-DFT of the odd samples.
24
ECE-600 Phil Schniter January 31, 2011
The radix-2 FFT (cont.):
The nal processing stage can be simplied from N mults
to
N
2
mults because the following are equivalent:
Lets examine the complexity of this split-in-half method:
direct N-DFT: N
2
mults,
split-in-half: (
N
2
)
2
+ (
N
2
)
2
+
N
2
=
1
2
(N
2
+ N) mults,
Since
1
2
(N
2
+ N) < N
2
for any N 1, it pays to split!
Thus, we split each
N
2
-DFT into two
N
4
-DFTs (combining
their outputs using twiddle factors), repeat with each
N
4
-DFT, and so on, nally obtaining
In total, (log
2
N) stages
N
2
mults
stage
=
N
2
log
2
N mults.
25
ECE-600 Phil Schniter January 31, 2011
Fast convolution:
The FFT gives us a very fast way to do linear convolution.
Say that we want to linearly convolve an M-length signal
x[n] with an L-length signal h[n], i.e.,
y[n] =
L1
l=0
h[l]x[n l],
requiring L mults per output, or ML mults in total.
If we zero-pad both sequences to length N M +L 1,
then N-circular convolution yields the same outputs as
linear convolution.
Furthermore, N-circular convolution can be implemented
as multiplication in the N-DFT domain:
x[n] N h[n] = T
1
N-DFT
_
T
N-DFT
x[n] T
N-DFT
h[n]
_
and, if we use FFT/IFFT to implement the DFT/IDFT,
this requires only 3
N
2
log
2
N + N total mults.
0 200 400 600 800 1000
2
4
6
8
10
12
14
16
L = N+1M
c
o
m
p
l
e
x
i
t
y
s
a
v
i
n
g
s
fast convolution, N=1024
Much cheaper
unless M or L
very small!
26
ECE-600 Phil Schniter January 31, 2011
Overlap-save:
Say that we want to lter M-length signal x[n] with
L-length lter impulse response h[n], where M L.
Say that we have access to an N-length FFT algorithm,
where L < N < M.
Rather than zero-padding x[n], we break it up into
overlapping segments of length N, and perform
fast convolution on each one.
Key quantities:
M+L1 = # linear-convolution outputs to compute
NL+1 = # useful outputs per N-circular convolution
M+L1
NL+1
= # N-circular convolutions needed in total
Example with L = 8, N = 32, M = 72:
N N
N N
L
L1 L1 L1
Total multiplies required for overlap-save:
N
2
log
2
N
. .
H=fft(h)
+
M+L1
NL+1
(
N
2
log
2
N
. .
X=fft(x)
+ N
..
Y=X*H
+
N
2
log
2
N
. .
y=ifft(Y)
)
Compare to ML multiplies for standard linear conv.
27
ECE-600 Phil Schniter January 31, 2011
Matrix/vector formulations:
Many of the properties weve seen so far can be eciently
described using matrices and vectors.
The N-DFT X[k] =
N1
n=0
x[n]e
j
2
N
nk
can be written in
matrix/vector form as
_
_
X[0]
X[1]
.
.
.
X[N1]
_
_
. .
X
=
_
_
e
j
2
N
00
e
j
2
N
01
e
j
2
N
0(N1)
e
j
2
N
10
e
j
2
N
11
e
j
2
N
1(N1)
.
.
.
.
.
.
.
.
.
.
.
.
e
j
2
N
(N1)0
e
j
2
N
(N1)1
e
j
2
N
(N1)(N1)
_
_
. .
W
_
_
x[0]
x[1]
.
.
.
x[N1]
_
_
. .
x
.
The k
th
row & n
th
column of DFT matrix W is e
j
2
N
kn
.
The IDFT matrix is W
1
=
1
N
W
H
, where ()
H
denotes
the Hermitian, i.e., conjugate transpose.
1
N
W
H
W = I =
1
N
WW
H
,
since
_
1
N
WW
H
n,m
=
1
N
N1
k=0
e
j
2
N
nk
e
j
2
N
km
=
1
N
N1
k=0
e
j
2
N
k(nm)
=
_
_
_
1 n = m
0 n ,= m
=
_
I
n,m
.
28
ECE-600 Phil Schniter January 31, 2011
Matrix/vector formulations (cont.):
Linear convolution y[n] =
l=
x[l]h[n l] can be
written as, for example,
_
_
y[0]
y[1]
y[2]
y[3]
y[4]
y[5]
y[6]
_
_
=
_
_
h[0] 0 0 0
h[1] h[0] 0 0
h[2] h[1] h[0] 0
h[3] h[2] h[1] h[0]
0 h[3] h[2] h[1]
0 0 h[3] h[2]
0 0 0 h[3]
_
_
_
_
x[0]
x[1]
x[2]
x[3]
_
_
,
while N-circular convolution y[n] =
N1
l=0
x[l]h[n l
N
]
can be written as
_
_
y[0]
y[1]
y[2]
y[3]
_
_
=
_
_
h[0] h[3] h[2] h[1]
h[1] h[0] h[3] h[2]
h[2] h[1] h[0] h[3]
h[3] h[2] h[1] h[0]
_
_
_
_
x[0]
x[1]
x[2]
x[3]
_
_
,
where the matrix has a circulant structure.
Circulant H with rst column h has eigendecomposition
H =
1
N
W
H
DW where D = diag(Wh).
Thus, circular convolution y = Hx can be written as
y =
1
N
W
H
DWx
which can be recognized as DFT-domain multiplication!
29