remarks on dft - trinity college dublin
TRANSCRIPT
Remarks on DFT
The two parameters that we have control over in the DFT are thesampling interval ∆t and the total number of points N thatdetermine the sampling period N∆t.
The sampling interval ∆t determines the range of frequencies thatcan be resolved (up to fNyquist = 1
2∆t ), while N determines thedetails that can be resolves (∆f = 1
N∆t )
Let’s look at some examples to see how the choice of ∆t and N∆taffects the DFT.
Example 1: What happens if the sample rate is too low? i.e. thesignal contains frequencies that are larger than the Nyquistfrequency.
Aliasing
Consider a sine function f (t) = sin(2πft), with f = 4Hz ,∆t = 0.2s and N = 32. fNyquist = 1/(2 · 0.2s) = 2.5 Hz. Therefore,f > fNyquist
Aliasing
Below is the power spectrum of the sine function.
There is a peak at 1 Hz and 4 Hz, where the latter corresponds tothe negative frequency −1 Hz.
Aliasing
The frequency f = 4 Hz is 1.5 Hz above the Nyquist frequency(2.5 Hz). It gets folded back into the frequency range below theNyquist frequency. This is called aliasing.Due to the symmetry YN/2−n = Y ∗N/2+n around the Nyquistfrequency, it appears as a low frequency fNyquist − 1.5 Hz = 1 Hz.This is what we see in the power spectrum.
Note: When sampling audio data, for example, a low pass filter isused to cut off frequencies beyond the audible spectrum of 20 KHzin order to avoid aliasing. The filter rolls off smoothly for a fewkHz. Therefore, CD’s audio are typically sampled at2 · 22050 = 44100 Hz after the filter applied.
Notes
Notes
Notes
Notes
Aliasing
Aliasing can be illustrated if we overplot a 1 Hz sinusoid onto thesampling points. On the ∆t = 0.2 sampling interval, 1 and 4 Hzfrequencies are indistinguishable.
DFT - comments I
When frequencies higher than 1/1∆t are present in a signalthat undergoes DFT, aliasing occurs. Typically this leads tofolding back of high frequency components to lowerfrequencies.
When sampling a signal at a certain sampling rate 1/∆t itmay be desirable to pass it through a low pass filter to get ridof frequencies above fNyquist.
When going from frequency back to the time domain, oftenget non-zero imaginary components, while the real part isreconstructed correctly.
Spectral/Frequency Leakage
Consider a triangular wave signal with period T = 3.2 s sampled at∆t = 0.1 s. The total number of sampling points is N = 500.Therefore, the total sampling period is 50 s.
Spectral/Frequency Leakage
Below is the computed Power spectrum |DFT (f (t))|2. Expect a aseries of equally spaced sharp peaks at integer multiples of thef = 1/T = 0.3125 Hz. However, peaks are broad!
Notes
Notes
Notes
Notes
Spectral/Frequency Leakage
Let’s increase the sampling period to 51.2 s, which is an integermultiple of the period of the triangular wave. The totalnumber of sampling points is now N = 512.
Spectral/Frequency Leakage
Peaks in the power spectrum (below) are sharp and occupy onlyfrequency bins at integer multiples of f .
Spectral/Frequency Leakage
Reason: DFT yields frequency spectrum at discrete frequenciesn
N∆t , with n = 0 . . .N/2− 1.
If frequency components of signal do not match thesediscrete frequencies exactly, frequency amplitudes getsmeared out. This is refereed to as “spectral leakage” or“frequency leakage”.
If the signal/function is periodic with frequency f = 1/T , we knowthat it contains only frequencies that are integer multiples of f . Bychoosing a sample period N∆t = mT , where m is an integer, weensure that frequency bins can match f exactly, so leakage isavoided.
Windowing
There is another way of mitigating the effects of spectral leakagein the power spectrum: Applying a window function to the signal.The Fourier transform of a finite sampling period can be consideredas a product between the infinite signal and the window function:
Notes
Notes
Notes
Notes
Windowing
Multiplication of two functions in the time domain corresponds toconvolution of their Fourier transforms in the frequency domain(Convolution theorem works in both directions). The discreteFourier transform of the rectangular window is just∑N−1
m=0 e−i2πmn/N . However, in order to see the leakage of the
absolute amplitudes, one looks at the square of the Fouriertransform:
Wn =1
N2
∣∣∣∣∣N−1∑m=0
e−i2πmn/N
∣∣∣∣∣2
=1
N2
[sin(πn)
sin(πn/N)
]2
This function has a main peak and side lobes. It is the side lobesthat smear out the frequency spectrum and cause leakage. Thegoal is to find a different window function where the side lobes falloff faster as a function of the frequency bins.
Windowing
There are plenty of window functions,but these are the mostcommon ones:
wj = 1−
∣∣∣∣∣ j − 12N
12N
∣∣∣∣∣ ≡ “Bartlett window”
wj =1
2
[1− cos
(2πj
N
)]≡ “Hann window”
wj =
(1−
j − 12N
12N
)2
≡ “Welch window”
Windowing
Numerical recipes (page 560)
Windowing
Numerical recipes (page 561)
Notes
Notes
Notes
Notes
Windowing
Example: Apply Hann window function to the triangular wave(N = 500), where period of the function is not commensurate withthe sampling period.
Windowing
Black points denote the power spectrum without the windowfunction, red points correspond to the power spectrum of theproduct of triangular wave with the window function. Peaks aremuch sharper!
DFT - comments II
If signal is periodic, the easiest way to avoid spectral leakageis to choose the sampling period to be an integer multiple ofthe period of the function.
For non-periodic signals or if periodicity is unknownwindowing can mitigate the effects of leakage. Choice ofwindow function determines trade-off between narrowness ofmain peak and the decay of the sidelobes. Rectangularwindow has narrow main peak (good to determine comparablestrength signals) but slow decay of sidelobes (bad for resolvingnearby frequency components).
Windowing can be useful when trying to resolve nearbyfrequencies that are masked/washed out by spectral leakage.
Optimal Wiener filtering
Previously we considered simple deconvolution of a signal that isnoise free. Recall the convolution theorem:
F[u ⊗ r ] = F[u]F[r ]
Therefore, if s = u ⊗ r , then
u = F−1
[F[s]
F[r ]
]However, in practice the measured signal s(t) is usually corruptedwith noise, which makes this method unreliable.
Notes
Notes
Notes
Notes
Optimal Wiener filtering
In general, a measured signal can be written as
c(t) = [u(t)⊗ r(t)] + n(t) (1)
c(t) = s(t) + n(t), (2)
where u(t) is the noise free, deconvoluted signal, r(t) the impulseresponse function and n(t) the noise term.
Goal: Construct a filter φ(t) (or Φ(f )) to be applied to c(t) (orC (f )) in order to obtain an estimate of the uncorrupted signal u(t)(or U(f )).In particular we will estimate the true signal U(f ) as follows:
U(f ) =C (f )Φ(f )
R(f )(3)
Optimal Wiener filtering
We demand U to be close to U in the mean square sense.Therefore we want to minimize the following integral:∫ ∞
−∞|u(t)− u(t)|2dt =
∫ ∞−∞|U(f )− U(f )|2df ,
where we used Parseval’s theorem.Substituting eqn.’s (2) and (3), we obtain
=
∫ ∞−∞
∣∣∣∣C (f )Φ(f )
R(f )− S(f )
R(f )
∣∣∣∣2 df ,=
∫ ∞−∞
∣∣∣∣ [S(f ) + N(f )]Φ(f )
R(f )− S(f )
R(f )
∣∣∣∣2 df ,
Optimal Wiener filtering
=
∫ ∞−∞
∣∣∣∣C (f )Φ(f )
R(f )− S(f )
R(f )
∣∣∣∣2 df ,=
∫ ∞−∞|R(f )|−2 |[S(f ) + N(f )]Φ(f )− S(f )|2 df ,
=
∫ ∞−∞|R(f )|−2 |S(f )[Φ(f )− 1] + N(f )Φ(f )|2 df
=
∫ ∞−∞|R(f )|−2
[|S(f )|2|1− Φ(f )|2 + |N(f )|2|Φ(f )|2
]df
In the last step cross product between N and S integrated over thefrequencies gives zero, since they are uncorrelated.
Optimal Wiener filtering
In order to find Φ(f ) that minimizes the integral we differentiatethe integrand and set it to zero:
∂
∂Φ(f )
[|S(f )|2|1− Φ(f )|2 + |N(f )|2|Φ(f )|2
]= 0
−2|S(f )|2|1− Φ(f )|+ 2|N(f )|2|Φ(f )| = 0
Therefore,
Wiener Filter
Φ(f ) =|S(f )|2
|S(f )|2 + |N(f )|2(4)
which we can use to estimate true signal:
U(f ) =C (f )Φ(f )
R(f )
Notes
Notes
Notes
Notes
Optimal Wiener filtering
Still a little problem
Φ(f ) =|S(f )|2
|S(f )|2 + |N(f )|2
The Wiener filter involves S , the smeared (convoluted signal) andthe noise N. However, we only know the measured noisy signalC (f ) = S(f ) + N(f ) (or c(t) = s(t) + n(t)).
How do we determine Φ(f ) ?
We can estimate |S(f )|2 and |S(f )|2 + |N(f )|2 from the powerspectrum of the measured signal c(t), since|C (f )|2 = |S(f )|2 + |N(f )|2.(This equation be proven via the Wiener-Khinchin theorem)
Optimal Wiener filtering
Extrapolate noise spectrum to separate |S(f )|2 and |N(f )|2(|N(f )|2 can be flat, tilted, smoothly varying - does not matter).
Optimal Wiener filtering
Remarks:
Quality of results second order in precision to which theoptimal filter is determined. Therefore, even a crudelydetermined filter (say 10 percent) can give excellent results.
For this reason separation of S and N by eye is sufficient forpractical purposes.
We do not need to know the response function r(t) (or R(f ))to find Φ(f ).
Don’t forget to extend filter Φ(f ) to negative frequenciesΦ(−f ) = Φ(f ).
Notice that Φ(f ) is close to unity where noise is negligible andclose to zero where noise is dominant. Wiener filter is theoptimal way to go between these extremes.
Notes
Notes
Notes
Notes