the discrete fourier transform - mcmaster university
TRANSCRIPT
The Discrete Fourier Transform
Signal Processing PSYCH 711/712Lecture 3
DFT Properties
• symmetry
• linearity
• shifting
• scaling
Symmetry
0 5 10 15
-10
-50
510
m
X(m)
0 5 10 15
-1.0
-0.5
0.0
0.5
1.0
n
x(n)
X(m) = complex conjugate{ X(N-m) }
DFT of even-symmetric
• for continuous waves:
- even-symmetry: f(t) = f(-t)
• for discrete, sampled waves
- even symmetry: x(n) = x(N-n)
• Fourier transform of even-symmetric waveforms is Real (i.e., Imaginary part is zero)
Even to Even
0 5 10 15
0.0
0.2
0.4
0.6
0.8
1.0
n
x(n)
0 5 10 15
-10
-50
510
m
X(m)
-10 -5 0 5
-10
12
34
5
m
Re{X(m)}
if x(n) is a real, even-symmetric function, then X(m) is a real, even-symmetric function
Odd-symmetry
f(t) = -f(-t), and f(0)=0or
x(n) = -x(N-n), and x(0)=0
0 5 10 15
-10
-50
510
m
X(m)
0 5 10 15
-1.0
-0.5
0.0
0.5
1.0
n
x(n)
Fourier transform of a real, odd-symmetric function is an imaginary, odd-symmetric function
DFT LinearityXsum(m) = X1(m) + X2(m)
0.0 0.2 0.4 0.6 0.8 1.0
-2-1
01
2
t
x(t)
x(t) = cos(2π3t− π/8) + sin(2π10t)
0 5 10 15
-1.5
-1.0
-0.5
0.0
0.5
1.0
1.5
m
phase{X(m)}
phase
0 5 10 15
0.0
0.1
0.2
0.3
0.4
0.5
m
mag{X
(m)}
/ N
magnitude
spectral components (m ≤ 19)
Shifting Property
Xshifted(m) = ej2πkm/NX(m)
if we start to sample x(n) at n=k, rather than n=0, the DFT of the shifted samples will be related to the DFT of the unshifted samples according to the equation:
Linear Phase Shifts
the shifting property implies that the effect of a shift, or delay, is to add a linear phase term to each spectral component:
Xshifted(m) = ej2πkm/NA(m)ejφ(m)
= A(m)ej(φ(m)+2πkm/N)
0 5 10 15
05
10
15
m
2*pi*k*m/N
k = 3; N = 20
!φ(m) =k2π
Nm
Scaling Property
• if the width of a function is increased, its Fourier Transform becomes narrower and taller; if its width is decreased, its transform becomes wider and shorter:
F
[x
(t
b
)]= |b|F (bf)
-4 -2 0 2 4
0.0
0.2
0.4
0.6
0.8
1.0
t
x(t)
0 5 10 15
0.0
0.1
0.2
0.3
0.4
0.5
mmag[X(m)]
Scaling Example
DFT Leakage
DFT of sinusoidal waves that are harmonics of 1/T, where T is the width of the sample, has non-zero magnitude only at spectral components corresponding to ± frequency of pattern
Frequency Representations of Sinusoids
DFT Leakage
Frequency representations of sine waves that are not harmonics of 1/T are represented as the sum of many non-zero spectral components
Why does leakage occur?
-2 -1 0 1 2
0.0
0.2
0.4
0.6
0.8
1.0
f(Hz)
Mag
-2 -1 0 1 2
0.0
0.5
1.0
1.5
2.0
time (sec)
x(t
)
-2 -1 0 1 2
0.0
0.5
1.0
1.5
2.0
time (sec)
x(t
)
fs = 10 Hz
x(t) = 1 + cos(2*pi*t)
-30 -20 -10 0 10 20 30
0.0
0.2
0.4
0.6
0.8
1.0
f (Hz)
Ma
g
continuous time continuous transform
Review Origins of DFT
continuous transformsampled time
Quartz (4) - Inactive
-2 -1 0 1 2
0.0
0.5
1.0
1.5
2.0
time (sec)
x(t
)
-30 -20 -10 0 10 20 30
0.0
0.2
0.4
0.6
0.8
1.0
f (Hz)
Ma
g
frequency representation of finite set of samples is a smeared version of the original
finite set of sampled points continuous transform10 samples
Quartz (4) - Inactive
-2 -1 0 1 2
0.0
0.5
1.0
1.5
2.0
time (sec)
x(t
)
-30 -20 -10 0 10 20 30
0.0
0.2
0.4
0.6
0.8
1.0
f (Hz)
Ma
g
-10 -5 0 5 10
-0.2
0.0
0.2
0.4
0.6
0.8
1.0
f (Hz)
Ma
g
-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10
frequency representation of finite set of samples is a smeared version of the original
finite set of sampled points continuous transform10 samples
where does this smoothing come from?
digression: convolution
Convolution
• A convolution is an integral that expresses the amount of overlap of one function g(t) as it is shifted over another function x(t).
u(t) = f(t) ∗ g(t) =∫ +∞
−∞f(τ)g(t− τ)dτ
Origins of Temporal Smearing
• truncation = multiplication by rect
• rect & sinc functions are related
• multiplication in time domain is equivalent to convolution in the frequency domain
• convolution causes frequency smearing
Convolution
• g(t-τ) is a flipped version of g(t) (i.e., reversed in time) that is centered on t
• the 2 functions are multiplied point-by-point
• the product is integrated, and the result is u(t)
• g(t-τ) is centered on new time t , and the process is repeated
u(t) = f(t) ∗ g(t) =∫ +∞
−∞f(τ)g(t− τ)dτ
u(t) = f(t) ∗ g(t) =∫ +∞
−∞f(τ)g(t− τ)dτ
covolution & smoothing
incr
ease
d sm
ooth
ing
f(x) * h(x) = g(x)
convolution with a delta function
g(x) = f(x)
convolution is linear
g(t) = f(t) * h(t)
replications of h(t) sum of replications
convolution & multiplication
• convolution in the time domain is equivalent to multiplication in the frequency domain
- Fourier Transform{x(n) * y(n)} = X(m) Y(m)
• convolution in the frequency domain is equivalent to multiplication in the time domain
- Fourier Transform{x(n) y(n)} = X(m) * Y(m)
What does this have to do with spectral
smoothing?
Quartz (4) - Inactive
-2 -1 0 1 2
0.0
0.5
1.0
1.5
2.0
time (sec)
x(t
)
X =
-2 -1 0 1 2
0.0
0.5
1.0
1.5
2.0
time (sec)
x(t
)
Temporal Truncation
Using a finite set of discrete values is equivalent to multiplying the original infinite set of samples by a rect function
-2 -1 0 1 2
0.0
0.2
0.4
0.6
0.8
1.0
time (sec)
x(t
)
rect(t)0.0
0.2
0.4
0.6
0.8
1.0
rect(t)
t
x(t)
-2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0
width = 1
0.0
0.2
0.4
0.6
0.8
1.0
rect(t-1)
t
x(t)
-2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0
0.0
0.2
0.4
0.6
0.8
1.0
rect(t/2)
t
x(t)
-2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0
0.0
0.2
0.4
0.6
0.8
1.0
rect((t-1)/2)
t
x(t)
-2.0 -1.5 -1.0 -0.5 0.0 0.5 1.0 1.5 2.0
rect(t-1)
rect(t/2)
rect((t-1)/2)
Multiplication & Convolution
• x(t) was multiplied by rect(t)
• equivalent to X(f) * Y(f)
- * is “convolution”
- Y(f) is Fourier Transform{rect(t)}
• Fourier Transform{rect(t)} = sinc(m)
• in this case, X(f) consists of sets of 3 delta functions centered on kfs
• so, X(f) * sinc(f) creates a series of sinc functions centered on each delta function
sinc(x) =sin(xπ)
xπ
sinc(t)=0 for all integer values of t except t=0, where sinc(0)=1
-20 -10 0 10 20
-0.2
0.0
0.2
0.4
0.6
0.8
1.0
sinc function
t
sinc(t)
-2 -1 0 1 2
0.0
0.2
0.4
0.6
0.8
1.0
time (sec)
x(t
)
rectangle wave
-4 -2 0 2 4
-0.2
0.0
0.2
0.4
0.6
0.8
1.0
f (Hz)
Am
plit
ude
sinc function
-4 -2 0 2 4
-0.2
0.0
0.2
0.4
0.6
0.8
1.0
f (Hz)
Mag
abs(sinc) function
Rect & Sinc are Fourier Transform Pairs
Fourier Transform {rect(x)} = sinc(f)
Fourier Transform Pairs
Fourier Transform {rect(x)} = sinc(f)Fourier Transform {sinc(x)} = rect(f)
-2 -1 0 1 2
0.0
0.2
0.4
0.6
0.8
1.0
time (sec)
x(t
)
rect(t)
-4 -2 0 2 4
-0.2
0.2
0.6
1.0
f (Hz)
Am
plit
ude
sinc(f)
-4 -2 0 2 4
-0.2
0.2
0.6
1.0
time (sec)
x(t
)
sinc(t)
-2 -1 0 1 2
0.0
0.2
0.4
0.6
0.8
1.0
f (Hz)
Am
plit
ude
rect(f)
Multiplication & Convolution
• x(t) rect(t) = X(f) * sinc(f)
• but, X(f) consists of sets of 3 delta functions centered on kfs
• so, X(f) * sinc(f) creates a series of sinc functions centered on each delta function
-10 -5 0 5 10
-0.2
0.0
0.2
0.4
0.6
0.8
1.0
f (Hz)
Ma
g
-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10
sum
-30 -20 -10 0 10 20 30
0.0
0.2
0.4
0.6
0.8
1.0
f (Hz)
Ma
g
Spectral Smoothing
• x(t) rect(t) = X(f) * sinc(f)
• X(f) is a series of delta functions
• so, X(f) * sinc(f) is a series of sinc functions
close up of smoothed spectrum that shows 3 individual sinc functions, one for each delta function, as well as the sum of the sinc functions.
• sampling x(t) creates periodic X(m)
• truncating x(t) creates smoothed X(m)
• but, we are using sampled (i.e., discrete) versions of X(m)
• consequences of sampling X(m)?
periodic x(t)
• sampling x(t) creates a periodic X(m)
- if sampling interval is ts, then replicates of X(m) are separated by fs = 1/ts
• and sampling X(m) creates a periodic x(t)
- sample frequency spectrum at sampling interval fs=1, then replicates of x(t) separated by 1/fs = 1 s
0.0 0.2 0.4 0.6 0.8 1.0
0.0
0.5
1.0
1.5
2.0
t
x(t)
0 1 2 3 4 5
0.0
0.5
1.0
1.5
2.0
t
x(t)
x(t) x(t) after sampling frequency spectrum
what does this have to do with DFT leakage?
non-harmonic frequencies
• leakage occurs when f is not an integer multiple of the number of samples
• when we concatenate the samples to create a periodic waveform, do we get a sine wave?
0 10 20 30 40 50
0.0
0.5
1.0
1.5
2.0
seq(0, 49)
tmp
0 1 2 3 4 5
0.0
0.5
1.0
1.5
2.0
t
x(t)
-2 -1 0 1 2
0.0
0.5
1.0
1.5
2.0
time (sec)
x(t
)
-2 -1 0 1 2
0.0
0.5
1.0
1.5
2.0
time (sec)
x(t
)
1.5 Hz sine wave
sampled & truncated
concatenated waveforms are periodic, but not sinusoidal
non-harmonic frequencies
• leakage occurs when f is not an integer multiple of the number of samples
• when we concatenate the samples to create a periodic waveform, do we get a sine wave?
• no, the periodic waveform is not sinusoidal and therefore the spectrum of that waveform will not be the same as a spectrum of a sine wave
• this is one explanation for why the spectrum of a non-harmonic sine wave looks strange
• another explanation can be found by inspecting the sampled spectrum itself
sampled spectra
-10 -5 0 5 10
-0.2
0.2
0.6
1.0
f
X(f)
signal f = 4 Hz
-10 -5 0 5 10
-0.2
0.2
0.6
1.0
f
X(f)
signal f = 4.5 Hz
leakage occurs as a result of sampling a continuous sinc(f) function that is centered on non-integer values of f
sampling frequency spectra
• cos(2 pi f0 t) rect(t) has a spectrum that consists of sinc functions centered on ±f0
• sinc(f0) is zero whenever f = f0 ± n
- n = 1, 2, 3, ... etc
• when f0 is an integer, X(m) will be exactly zero at all integer frequencies, m ≠ ±f0
- X(m) = 0 for all integer m ≠ ±f0
• but, when f0 is not an integer, the sampled spectrum X(m) will not be zero at m ≠ f0
coarse frequency sampling
• Continuous frequency spectra of truncated data always contain the fingerprints of sinc functions
• we sometimes fail to see them because of the coarse sampling of the frequency spectrum (fs=1)
• but we can get a better look by increasing the rate at which the frequency spectrum is sampled...
increasing frequency resolution
• Suppose we record 1s worth of data sampled at 10 Hz:- T = 1s; ts = 0.1 s; n=(0...9); N = 10
- The spectral components m=1 and m=2 are complex exponentials with frequencies of 1 & 2 cycles per second
- or 1 and 2 Hz
• Let’s increase T to 2s:- T = 2s; ts = 0.1 s; n=(0...19); N = 20
- The spectral components m=1 and m=2 have frequencies of 1 & 2 cycles per two seconds
- ... or 0.5 and 1 Hz
• doubling N doubled our frequency resolution
0.0 0.5 1.0 1.5 2.0
-1.0
-0.5
0.0
0.5
1.0
f = 1.5 Hz
t
x(t)
0.0 0.5 1.0 1.5 2.0
-1.0
-0.5
0.0
0.5
1.0
f = 1.5 Hz
t
x(t)
0 5 10 15
02
46
810
m
mag[X(m)]
0 5 10 15
02
46
810
m
mag[X(m)]
f = m fs / N = msampling rate = fs = 10 HzN = 10
sampling rate = fs = 10 HzN = 20 f = m fs / N = m/2
0 1 2 3 4
-1.0
-0.5
0.0
0.5
1.0
f = 1.25 Hz
t
x(t)
0 1 2 3 4
-1.0
-0.5
0.0
0.5
1.0
f = 1.25 Hz
t
x(t)
0 10 20 30 40
05
10
15
20
m
mag[X(m)]
0 5 10 15
05
10
15
20
m
mag[X(m)]
0 5 10 15 20
-1.0
-0.5
0.0
0.5
1.0
f = 1.25 Hz
t
x(t)
0 1 2 3 4
-1.0
-0.5
0.0
0.5
1.0
f = 1.25 Hz
t
x(t)
zero stuffing(also improves frequency resolution)
0 50 100 150 200
05
10
15
20
m
mag[X(m)]
0 1 2 3 4 5 6 7 8 9 10
N.B. Amplitude of X(m) not altered by zero stuffing.
0 10 20 30 40
05
10
15
20
m
mag[X(m)]
0 1.25 2.5 3.75 5 6.25 7.5 8.75 10
continuous abs(sinc(m)) function
0.0 0.5 1.0 1.5 2.0
-1.0
0.0
0.5
1.0
t
x(t)
Hanning Window
0.0 0.5 1.0 1.5 2.0
-1.0
0.0
0.5
1.0
t
x(t)
Hamming Window
0.0 0.5 1.0 1.5 2.0
-1.0
0.0
0.5
1.0
t
x(t)
0.0 0.5 1.0 1.5 2.0
-1.0
0.0
0.5
1.0
t
x(t)
Triangle Window
Application of Windows
0 5 10 15 20
-1.0
-0.5
0.0
0.5
1.0
n
x(n)
0 5 10 15
02
46
810
m
mag[X(m)]
0 5 10 15
02
46
810
m
mag[X(m)]
Windows Reduce Frequency Spread
0 5 10 15 20
-1.0
-0.5
0.0
0.5
1.0
n
x(n)
Hamming Window
the end