36
Discrete Fourier Transform

Discrete Fourier Transform - IMT

  • Upload
    others

  • View
    32

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Discrete Fourier Transform - IMT

Discrete Fourier Transform

Page 2: Discrete Fourier Transform - IMT

Discrete Fourier Transform (DFT)

The DFT of a finite signal (FS) defined on {0, … , 𝑁 − 1} is another FS defined on the same support {0, … , 𝑁 − 1}:

∀𝑘 ∈ 0,1, … , 𝑁 − 1 , 𝑢 𝑘= 𝑢𝑛𝑒−2𝑖𝜋

𝑘𝑁𝑛

𝑁−1

𝑛=0

The index of 𝑢 is 𝑘, but the corresponding wave frequency is 𝑘/𝑁

Page 3: Discrete Fourier Transform - IMT

Inversion theorem

The inversion formula is:

𝑢𝑛 =1

𝑁 𝑢 𝑘𝑒

2𝑖𝜋𝑘𝑁𝑛

𝑁−1

𝑘=0

proof :

1

𝑁 𝑢 𝑘𝑒

2𝑖𝜋𝑘𝑁𝑛

𝑁−1

𝑘=0

=1

𝑁 𝑢𝑚𝑒

−2𝑖𝜋𝑘𝑁𝑚

𝑁−1

𝑚=0

𝑒2𝑖𝜋𝑘𝑁𝑛

𝑁−1

𝑘=0

=1

𝑁 𝑢𝑚 𝑧𝑘

𝑁−1

𝑘=0

𝑁−1

𝑚=0

with 𝑧 = 𝑒2𝑖𝜋𝑛−𝑚

𝑁

Page 4: Discrete Fourier Transform - IMT

Inversion theorem

Given that 𝑧 = 𝑒2𝑖𝜋𝑛−𝑚

𝑁 , we find easily :

𝑧𝑘𝑁−1

𝑘=0

= 𝑁𝛿𝑛−𝑚 ∀𝑛,𝑚, ∈ {0,1, … , 𝑁 − 1}

By replacing in the previous equation we find :

1

𝑁 𝑢 𝑘𝑒

2𝑖𝜋𝑘𝑁𝑛

𝑁−1

𝑘=0

=1

𝑁 (𝑢𝑚𝑁𝛿𝑛−𝑚 )

𝑁−1

𝑚=0

= 𝑢𝑛

In other terms, 𝑢 (𝑘)

𝑁 are the coefficients of a decomposition on a Fourier

basis

Page 5: Discrete Fourier Transform - IMT

Classical properties

𝑢 = 𝛿𝑚 ⇒ 𝑢 𝑘 = 𝑒−2𝑖 𝜋

𝑚𝑁𝑘

ℱ 𝑢⊛𝑁 𝑣 = 𝑢 𝑣

ℱ 𝑢𝑣 =1

𝑁𝑢 ⊛𝑁 𝑣

ℱ 𝜙𝑢 = 𝑢 𝑘 − 𝑘0 𝜙𝑛 = 𝑒2𝑖 𝜋𝑘0𝑁𝑛

ℱ 𝑢𝑚 = 𝑢 𝑘𝑒−2𝑖 𝜋

𝑚𝑁𝑛

Symmetry properties

Circular convolution

Circular permutation

Page 6: Discrete Fourier Transform - IMT

Parseval “equality”

• Fourier waves are orthogonal with norm 𝑁

• We deduce:

𝑢 2 = 𝑢 𝑘2

𝑁−1

𝑘=0

= 𝑢𝑛𝑒−2𝑖𝜋

𝑘𝑁𝑛

𝑁−1

𝑛=0

𝑁−1

𝑘=0

𝑢 𝑚𝑒2𝑖𝜋𝑘𝑁𝑚

𝑁−1

𝑚=0

= 𝑢𝑛𝑢 𝑚

𝑁−1

𝑚=0

𝑁−1

𝑛=0

𝑒−2𝑖𝜋𝑘𝑁(𝑛−𝑚)

𝑁−1

𝑘=0

= 𝑁 𝑢 2

Page 7: Discrete Fourier Transform - IMT

Links between DT and DTFT

• DFT is the only transform that can be computed on a computer …

• DFT can approximate DTFT under certain hypotheses

Page 8: Discrete Fourier Transform - IMT

Case of a finite support sequences

• Consider 𝑢 defined on ℤ, with finite support:

𝑢𝑛 = 0 ∀𝑛 ∉ {0,… ,𝑁 − 1}.

• Let 𝑣 be the restriction of 𝑢 to {0,… ,𝑀 − 1}, with 𝑀 ≥ 𝑁,

𝑣 𝑘 = 𝑣𝑛𝑒−2𝑖𝜋

𝑘𝑀𝑛

𝑀−1

𝑛=0

= 𝑢 𝑘

𝑀

• Sometimes 𝑣 is called M-DFT of 𝑢 (zero-padding)

• We talk about 𝑀-DFT of a finite support sequence

Page 9: Discrete Fourier Transform - IMT

Case of a finite support series

• By changing 𝑀, one can sample 𝑢 𝜈 as finely as necessary

• This is equivalent to a zero-padding

• However, one needs only 𝑁 samples of 𝑢 𝜈 to perfectly know (reconstruct) 𝑢

𝑢 𝑘

𝑁𝑘∈{0,…,𝑁−1}

DFT−I 𝑢DTFT

𝑢 (𝜈)

• How to generalize ? When is it possible with

samples at 1

𝑁 to reconstruct a function of real

variable?

Page 10: Discrete Fourier Transform - IMT

Signal on Z (left) and its DTFT (right) Support {0, …, 59}

Example

Page 11: Discrete Fourier Transform - IMT

Right: 60-DFT (indexed by k) of the non null part of the signal on left.

Example

Page 12: Discrete Fourier Transform - IMT

Indexed by 𝑘/𝑀 and periodized by period 1

to remain in the interval −1

2,1

2

Example

Page 13: Discrete Fourier Transform - IMT

Superposition of DFT and DTFT. As 𝑀 ≥ 𝑁 the DFT is a perfect sampling of the DFTF

Page 14: Discrete Fourier Transform - IMT

Wave frequency determination

• We observe 𝑁 samples of a wave signal.

• From these samples, we want to find the wave frequency

Page 15: Discrete Fourier Transform - IMT

Wave frequency calculation

∀𝑛 ∈ ℤ, 𝑢𝑛 = 𝑒2𝑖𝜋𝜈0𝑛 i.e., 𝑢 = 𝜙, FW at frequency 𝜈0

We can only observe a finite number of samples; we have 𝑢𝑇 = 𝜙𝑤

where 𝑤 is a finite support sequence:

𝑤𝑛 = 1 if 𝑛 ∈ {0,…𝑁 − 1}0 otherwise

Rectangular window

Page 16: Discrete Fourier Transform - IMT

Wave frequency calculation

• The DTFT of 𝑢𝑇: ℱ(𝑢𝑇) = ℱ 𝜙𝑤

= 𝑤 𝜈 − 𝜈0

We find:

𝑤 𝜈 =sin 𝜋𝑁𝜈

sin 𝜋𝜈

Then, 𝜈0 is the position

of the maximum of ℱ(𝑢𝑇) -0.5 -0.4 -0.3 -0.2 -0.1 0 0.1 0.2 0.3 0.4 0.50

2

4

6

8

10

12

14

16

18

20

𝑤 𝜈 for N=20

Page 17: Discrete Fourier Transform - IMT

DTFT of a wave of frequency 0,123 trunkated at 20 samples

Page 18: Discrete Fourier Transform - IMT

Wave frequency calculation

• Problem : we cannot compute 𝑢𝑇 𝜈 , but only its samples at 1/𝑀

• The position of the maximum will therefore be known with a precision related to the order 𝑀 of the DFT and rather than to the duration of the observation, 𝑁

Page 19: Discrete Fourier Transform - IMT

• 30-DFT (left) and 60-DFT (right) • The precision for the frequency computation is 1/𝑀 • We select the index k for which the DFT is maximum

Page 20: Discrete Fourier Transform - IMT

Separation of two frequencies (waves)

• The duration of observation affects the frequency resolution

• We consider a mixture of two Fourier waves, observed over 𝑁 samples:

𝑢𝑛 = 𝐴0𝑒2𝑖𝜋𝜈0𝑛 + 𝐴1𝑒

2𝑖𝜋𝜈1𝑛

Page 21: Discrete Fourier Transform - IMT

𝑁 = 20. Left : the 2 DTFT; right: their sum. We cannot distinguish two close

frequency waves (at less than 1/𝑁)

Frequency resolution

Page 22: Discrete Fourier Transform - IMT

𝑁 = 60 We can now distinguish the two frequencies

Frequency resolution

Page 23: Discrete Fourier Transform - IMT

• The DFT of the 2 waves mixture is :

𝐴0𝑤𝑘

𝑀− 𝜈0 + 𝐴1𝑤

𝑘

𝑀− 𝜈1

• If 𝐴0 = 𝐴1, the two peaks can be separated if their lobes are separated by a half-amplitude

• The amplitude of the lobe depends on the window:

for the stair window it is 1

𝑁

• The condition is, in this case: 𝑁 ≥1

|𝜈0−𝜈1|

Frequency resolution

Page 24: Discrete Fourier Transform - IMT

Very different amplitudes, masking and windowing problems

• In order to improve frequency resolution, one has to increase the number of observed samples 𝑁, if possible.

• This does not depend on the order 𝑀 of the DFT

– We still need to insure 𝑀 ≥ 𝑁

• What happens if the two waves have very different amplitudes?

Page 25: Discrete Fourier Transform - IMT

Left: DTFT of two waves. Right: DTFT of their sum.

Secondary peaks mask the second wave.

Page 26: Discrete Fourier Transform - IMT

Choice of the window shape

Top: Hamming window. Bottom: stair (or rectangular) window

Size 30 in both cases

Page 27: Discrete Fourier Transform - IMT

Left : DTFT of a stair window of size 30. Right : DTFT of a Hamming window.

Choice of the window shape

Page 28: Discrete Fourier Transform - IMT

Multiplication by the Rectangular window

Multiplication by the Hamming window

Page 29: Discrete Fourier Transform - IMT

Frequency analysis: conclusion

• Calculation of the frequency for a Fourier wave: precision = 1/𝑀

• Separation of 2 waves with the same amplitude : Δ𝜈 ≥ 1/𝑁

• Separation of 2 waves with very different amplitudes : depends on the ratio between the amplitude of the principal and secondary lobes

– This does not depend on 𝑁 , but on the shape of the window

Page 30: Discrete Fourier Transform - IMT

The spectrogram

• The idea of the spectrogram is to locally analyze the frequency content of a signal.

• Around each signal sample, we keep a window on which we compute a DTFT (through a DFT)

• For a signal u and a window w centered in zero:

∀𝑛 ∈ ℤ, ∀𝜈 ∈ −1

2,1

2, 𝑈 𝑛, 𝜈 = 𝑢𝑚𝑤𝑚−𝑛𝑒

−2𝑖𝜋𝜈𝑚

𝑚∈ℤ

We can compute directly the samples of 𝑈 𝑛, 𝜈 through ∀𝑛 ∈ ℤ, ∀𝑘 ∈ {0,…𝑀 − 1},

𝑈 𝑛,𝑘

𝑀= 𝑢𝑚𝑤𝑚−𝑛𝑒

−2𝑖𝜋𝑘𝑀𝑚

𝑚∈ℤ

Page 31: Discrete Fourier Transform - IMT

The spectrogram

• For 𝑛 (time index) fixed, we have the formula

∀𝜈 ∈ −1

2,1

2, 𝑈 𝑛, 𝜈 = 𝑢𝑚𝑤𝑚−𝑛𝑒

−2𝑖𝜋𝜈𝑚

𝑚∈ℤ

• This means that 𝑈(𝑛, 𝜈) is the DTFT of 𝑢 multiplied by the window𝑤 translated by 𝑛 : frequency analysis around the time instant 𝑛

Page 32: Discrete Fourier Transform - IMT

The spectrogram

• For a fixed frequency, we have the formula:

𝑈 𝑛, 𝜈0 = 𝑢𝑚𝑤𝑚−𝑛𝑒−2𝑖𝜋𝜈0(𝑛−𝑚)𝑒−2𝑖𝜋𝜈0𝑛

𝑚

𝑈 𝑛, 𝜈0 = 𝑢𝑚𝑤𝑚−𝑛𝑒−2𝑖𝜋𝜈0 𝑛−𝑚

𝑚

= < 𝑢,𝜓𝑛 >

𝜓 = 𝑤𝜙𝜈0

Scalar product between 𝑢 and 𝜓𝑛: similitude between 𝑢 and a « wave » truncated around 𝑛 and with frequency 𝜈0

Page 33: Discrete Fourier Transform - IMT

Spectrogram display

• Since we have real signals, the module of the DTFT is symmetrical.

• Time axis is 𝑥 and frequency axis is 𝑦 (in Hz)

• We use a logarithmic scale for the module, otherwise certain frequencies will « smash » the others (ear sensitivity is btw logarithmic)

Page 34: Discrete Fourier Transform - IMT

Example

Left: DTFT; right: spectrogram of the same signal. The DTFT does not allow to know at which time instant arrives the wave at 15000Hz.

Page 35: Discrete Fourier Transform - IMT

Observation of a sound on the spectrogram

Piano: Original

Page 36: Discrete Fourier Transform - IMT

Spectrogram of the mp3-encoded version

MP3: 128kbits/s