The Discrete Fourier Transform -...

16
DSP (2007) The Discrete Fourier Transform NCTU EE 1 The Discrete Fourier Transform What is Discrete Fourier Transform (DFT)? (Note: It’s not DTFT – discrete-time Fourier transform) A linear transformation (matrix) Samples of the Fourier transform (DTFT) of an aperiodic (with finite duration) sequence Extension of Discrete Fourier Series (DFS) Review: FT, DTFT, FS, DFS Time signal Transform Coeffs. (periodic/aperiodic) Coeffs. (conti./discrete) Analog aperiodic FT Aperiodic Continuous Analog periodic FT FS Aperiodic Aperiodic Continuous (impulse) Discrete Discrete aperiodic DTFT Periodic Continuous Discrete periodic DFS Periodic Discrete Discrete finite-duration DFT

Transcript of The Discrete Fourier Transform -...

Page 1: The Discrete Fourier Transform - twins.ee.nctu.edu.twtwins.ee.nctu.edu.tw/courses/dsp_08/dsp8.pdfLinear Convolution Using DFT ... Method 1 – overlap and add ... The Discrete Fourier

DSP (2007) The Discrete Fourier Transform

NCTU EE 1

The Discrete Fourier Transform

• What is Discrete Fourier Transform (DFT)? (Note: It’s not DTFT – discrete-time Fourier transform)

A linear transformation (matrix) Samples of the Fourier transform (DTFT) of an aperiodic (with finite duration) sequence Extension of Discrete Fourier Series (DFS)

• Review: FT, DTFT, FS, DFS Time signal Transform Coeffs.

(periodic/aperiodic) Coeffs.

(conti./discrete) Analog aperiodic FT Aperiodic Continuous Analog periodic FT

FS Aperiodic Aperiodic

Continuous (impulse)Discrete

Discrete aperiodic DTFT Periodic Continuous Discrete periodic DFS Periodic Discrete Discrete finite-duration DFT

Page 2: The Discrete Fourier Transform - twins.ee.nctu.edu.twtwins.ee.nctu.edu.tw/courses/dsp_08/dsp8.pdfLinear Convolution Using DFT ... Method 1 – overlap and add ... The Discrete Fourier

DSP (2007) The Discrete Fourier Transform

NCTU EE 2

The Discrete Fourier Series • Properties of NW

kN

jkN

NjN eWeW

ππ

22

thus,−−

==

-- NW is periodic with period N. (It is essentially cos and sin) : L=== ±± NkN

NkN

kN WWW 2

-- ∑−

= ⎭⎬⎫

⎩⎨⎧

≠=

=1

0 if ,0 if ,N

k

lkN mNl

mNlNW

(Pf) (i) 1 , If 0 ===⋅= ⋅N

NmkN

lkN WWWNml

NWN

k

N

k

lkN == ∑∑

=

=

1

0

1

01

(ii) 1 , If ≠⋅≠ lNWNml

01

111

1 1

0=

−−

=−−

=⋅−

=∑ l

Nl

N

NlN

N

k

lkN WW

WW

-- [ ] [ ]∑ ∑−

=

−∞=−==

1

0

1 N

k m

lkN mNlW

NlY δ

• DFS for periodic sequences

][~ nx

n

[ ] [ ] NperiodrNnxnx ,~~ +=

Its DFS representation is defined as follows:

Synthesis equation: [ ] [ ] [ ]∑∑−

=

−−

===

1

0

1 2 ~1~1~ N

k

knN

N

ok

knN

jWkX

NekX

Nnx

π

Analysis equation: [ ] [ ]∑−

==

1

0

~~ N

n

knnWnxkX

Note: The tilde in x~ indicates a periodic signal.

][~ kX is periodic of period N.

Page 3: The Discrete Fourier Transform - twins.ee.nctu.edu.twtwins.ee.nctu.edu.tw/courses/dsp_08/dsp8.pdfLinear Convolution Using DFT ... Method 1 – overlap and add ... The Discrete Fourier

DSP (2007) The Discrete Fourier Transform

NCTU EE 3

Pf) [ ] [ ]∑−

=

−=1

0

~1~ N

k

knNWkX

Nnx

Pick an r ( Nr <≤0 )

rnNW× [ ] [ ] rn

N

N

k

knN

rnN WWkX

NWnx ⋅= ∑

=

−1

0

~1~

∑−

=

1

0

N

n

[ ] [ ]

[ ]

[ ] [ ] [ ][ ]rX

rkXXX

WkXN

WWkXN

Wnx

N

n

nkrN

N

k

rnN

N

k

knN

N

n

N

n

rnN

~ 1~01~00~

)~(1

~1~

1

0

)(1

0

1

0

1

0

1

0

=

+⋅=++⋅+⋅=

=

⋅=

∑∑

∑∑∑−

=

−−

=

=

−−

=

=

LL

That is, [ ] [ ]∑−

==

1

0

~~ N

n

rnNWnxrX . QED

Example: Periodic Rectangular Pulse Train

[ ] ∑=

⎟⎠⎞

⎜⎝⎛

⎟⎠⎞

⎜⎝⎛

=−−

==4

0

104

10

510

10

10sin

2sin

11~

n

kj

k

kKn

k

k

eWWWkX

π

ππ

Page 4: The Discrete Fourier Transform - twins.ee.nctu.edu.twtwins.ee.nctu.edu.tw/courses/dsp_08/dsp8.pdfLinear Convolution Using DFT ... Method 1 – overlap and add ... The Discrete Fourier

DSP (2007) The Discrete Fourier Transform

NCTU EE 4

Sampling the Fourier Transform Compare two cases:

(1) Periodic sequence [ ] ][~~ kXnx ↔

(2) Finite duration sequence [ ]nx = one period of [ ]nx~

An aperiodic sequence:

[ ] ( )

[ ] [ ] ( )k

N

j

j

eXkXIDFSnx

eXFTnx

πω

ω

ω

2|~~samples ?

==←←

→→

b Compare:

( ) ( )

[ ] ( )ωjeXDTFTnx

jXFTtx

→→

Ω→→

? samples b

Example: [ ]

⎩⎨⎧ ≤≤

=otherwiase

nnx

,040,1 [ ]

integer109105,0

10410,1~

=⎩⎨⎧

+≤≤++≤≤

=

rrnr

rnrnx

Page 5: The Discrete Fourier Transform - twins.ee.nctu.edu.twtwins.ee.nctu.edu.tw/courses/dsp_08/dsp8.pdfLinear Convolution Using DFT ... Method 1 – overlap and add ... The Discrete Fourier

DSP The Discrete Fourier Transform

NCTU EE 5

[ ] [ ]

( )

[ ]

[ ]

[ ]

[ ] [ ] [ ]∑ ∑

∑∑ ∑

∑ ∑

∑ ∑

−∞=

−∞=

−∞=

=

=

−∞

−∞=

=

−∞=

=

=

+=+∗=

⎭⎬⎫

⎩⎨⎧=

⎟⎟⎠

⎞⎜⎜⎝

⎛=

⎟⎠⎞

⎜⎝⎛=

⎟⎟⎠

⎞⎜⎜⎝

⎛=

=

r r

m

N

k

knN

kmN

N

k

knN

m

kmN

j

knN

kk m

mj

knN

k kN

j

N

k

KnN

rNnxrNnnx

WWmxN

WemxN

WemxN

WeXN

WkXN

nx

δ

π

πω

ω

πωω

) ge(Interchan 1

1

(FT) 1

(Sampling) 1

(IDFS) ~1~

1

0

1

0

2

2

2

1

0

If x[n] has finite length and we take a sufficient number of equally spaced samples of its Fourier Transform ( a number greater than or equal to the length of x[n]), then x[n] is re-coverable from [n]x~ .

Page 6: The Discrete Fourier Transform - twins.ee.nctu.edu.twtwins.ee.nctu.edu.tw/courses/dsp_08/dsp8.pdfLinear Convolution Using DFT ... Method 1 – overlap and add ... The Discrete Fourier

DSP The Discrete Fourier Transform

NCTU EE 6

• Two ways (equivalently) to define DFT:

(1) N samples of the DTFT of a finite duration sequence [ ]nx

(2) Make the periodic replica of [ ]nx [ ]nx~

Take the DFS of [ ]nx~

Pick up one segment of ][~ kX

[ ]

[ ] [ ]kXDFSnx

kXDFTnx

~~segment one periodic

][

→→

↑↓

→→

Properties of the Discrete Fourier Series -- Similar to those of FT and z-transform • Linearity

[ ] [ ][ ] [ ]

[ ] [ ] [ ] [ ]kXbkXanxbnxakXnxkXnx

212122

11 ~~~~~~

~~+↔+⇒

⎭⎬⎫

• Shift

[ ] [ ]kXnx ~~ ↔ ==> [ ] [ ][ ] [ ]lkXnxW

kXWmnxnl

N

kmN

−↔

↔−− ~~

~~

• Duality

Def: [ ] [ ]

[ ] [ ]⎪⎪⎩

⎪⎪⎨

=

=

∑−

=

=

1

0

1

0

)(#~~

(*)~1~

N

n

nkN

N

k

knN

WnxkX

WkXN

nx

[ ] [ ][ ] [ ]⎩

⎨⎧

−↔

kxNkXkXnx~~

~~

Page 7: The Discrete Fourier Transform - twins.ee.nctu.edu.twtwins.ee.nctu.edu.tw/courses/dsp_08/dsp8.pdfLinear Convolution Using DFT ... Method 1 – overlap and add ... The Discrete Fourier

DSP The Discrete Fourier Transform

NCTU EE 7

• Symmetry [ ] [ ]kXnx ~~ ↔

[ ]{ } [ ] [ ] [ ]( )

[ ]{ } [ ] [ ] [ ]( )⎟⎠⎞

⎜⎝⎛ −−=↔

⎟⎠⎞

⎜⎝⎛ −+=↔

kXkXkXnxj

kXkXkXnx

o

e

*

*

~~21~~Im

~~21~~Re

[ ] [ ] [ ]( ) [ ]{ }

[ ] [ ] [ ]( ) [ ]{ }kXjnxnxnx

kXnxnxnx

o

e

~Im~~21~

~Re~~21~

*

*

↔−−=

↔−+=

[ ] [ ] [ ]kXkXnx −= *~~ real, is ~ If . [ ] [ ][ ] [ ][ ]{ } [ ]{ }[ ]{ } [ ]{ }⎩

⎨⎧

−−=

−=⇒

⎪⎩

⎪⎨⎧

−−∠=∠

−=⇒

kXkXkXkX

kXkX

kXkX

~Im~Im

~Re~Re

~~

~~

• Periodic Convolution [ ] [ ]nxnx 21

~,~ are periodic sequences with period N

[ ] [ ] [ ] [ ]

[ ] [ ] [ ] [ ] [ ]∑

∑−

=

=

−↔=

↔−

1

021213

1

02121

~~1~~~

~~~~

N

l

N

m

lkXlXN

nxnxnx

kXkXmnxmx

Page 8: The Discrete Fourier Transform - twins.ee.nctu.edu.twtwins.ee.nctu.edu.tw/courses/dsp_08/dsp8.pdfLinear Convolution Using DFT ... Method 1 – overlap and add ... The Discrete Fourier

DSP The Discrete Fourier Transform

NCTU EE 8

Discrete Fourier Transform • Definition [ ]nx : length N, 10 −≤≤ Nn Making the periodic replica:

[ ] [ ]

( )[ ]( )( )[ ]N

r

nxNnx

rNnxnx

≡≡

+= ∑∞

−∞=

modulo

~

[ ] [ ]∑−

==

1

0

~~ N

n

knNWnxkX

Keep one segment (finite duration)

[ ] [ ]⎩⎨⎧ −≤≤

=otherwise ,0

10 ,~ NkkXkX That is, [ ] ]))[((~

NkXkX =

This finite duration sequence ][kX is the discrete Fourier transform (DFT) of [ ]nx

[ ] [ ]

[ ] [ ] 10,1 :

10, :

1

0

1

0

−≤≤=

−≤≤=

∑−

=

=

NnWkXN

nxeqnSynthesis

NkWnxkXeqnAnalysis

N

k

knN

N

n

knN

Remark: DFT formula is the same as DFS formula. Indeed, many properties of DFT are de-rived from those of DFS.

Page 9: The Discrete Fourier Transform - twins.ee.nctu.edu.twtwins.ee.nctu.edu.tw/courses/dsp_08/dsp8.pdfLinear Convolution Using DFT ... Method 1 – overlap and add ... The Discrete Fourier

DSP The Discrete Fourier Transform

NCTU EE 9

Properties of Discrete Fourier Transform • Linearity

[ ] [ ][ ] [ ] [ ] [ ] [ ] [ ]

[ ]21

212122

11

,max

NNlength

kbXkaXnbxnaxkXnxkXnx

=

+↔+⇒⎭⎬⎫

↔↔

• Circular Shift

[ ] [ ]kXnx ↔ ==> ( )( )[ ] [ ][ ] ( )( )[ ]NN

kmNN

lkXnxW

kXWmnx

−↔

↔−−ln

(Pf) From the right side of the 2nd eqn.

[ ] [ ] [ ]

( )( )[ ] ( )( )[ ] [ ]mnxmnxmnx

kXekXekXW

NN

kmN

jkmN

jKmN

−=−←−↓

→=

~IDFS DFT

~22

b

ππ

QED

Remark: This is circular shift not linear shift. (Linear shift of a periodic sequence = circular shift of a finite sequence.)

Page 10: The Discrete Fourier Transform - twins.ee.nctu.edu.twtwins.ee.nctu.edu.tw/courses/dsp_08/dsp8.pdfLinear Convolution Using DFT ... Method 1 – overlap and add ... The Discrete Fourier

DSP The Discrete Fourier Transform

NCTU EE 10

• Duality

[ ] [ ][ ] ( )( )[ ] 1-Nk0 , ≤≤−↔↔

NkNxnXkXnx

• Symmetry Properties

[ ][ ]

( )( )[ ] ( )( )[ ]{ }

[ ] [ ]{ }[ ]{ }⎪⎩

⎪⎨⎧

=

≤≤−+=

≤≤+=

=

0 ,0Re

11 ,21

10 ,21

~

symmetric-conjugate periodic

*

*

nx

N-n nNxnx

N-n nxnx

nx

nx

NN

e

ep

[ ]

[ ] [ ]{ }[ ]{ }⎪⎩

⎪⎨⎧

=

≤≤−−=

=

0 ,0Im

11 ,21

ricantisymmet-conjugate periodic

*

nx

N-nnNxnx

nxop

[ ] [ ]{ } [ ] [ ]{ }kXjnxkXnx opep Im Re ↔↔

[ ] [ ] ( )( )[ ]

[ ] ( )( )[ ][ ]{ } ( )( )[ ]

[ ]{ } ( )( )[ ]{ }[ ]{ } ( )( )[ ]{ }⎩

⎨⎧

−−=−=

⇒⎩⎨⎧

−−∠=∠

−=⇒

−≤≤−=

N

N

N

N

N

kXkXkXkX

kXkXkXkX

NkkXkX nx

ImImReRe

10, real, If *

[ ]{ } [ ] ( )( )[ ] ( )( )[ ]{ }

[ ]{ } [ ] ( )( )[ ] ( )( )[ ]{ }⎪⎪⎩

⎪⎪⎨

−−=↔

−+=↔

NNop

NNep

kXkXkXnx

kXkXkXnx

*

*

21Im

21Re

Page 11: The Discrete Fourier Transform - twins.ee.nctu.edu.twtwins.ee.nctu.edu.tw/courses/dsp_08/dsp8.pdfLinear Convolution Using DFT ... Method 1 – overlap and add ... The Discrete Fourier

DSP The Discrete Fourier Transform

NCTU EE 11

• Circular Convolution

[ ] [ ] [ ]

[ ] ( )( )[ ]

[ ] [ ] [ ] [ ]kXkXnxnx

mnxmx

nxnxnxN

mN

2121

1

0

213

↔Θ

−≡

Θ=

∑−

=

N-point circular convolution

Example: N-point circular convolution of two constant sequences of length N

2L-point circular convolution of two constant sequences of length L

Page 12: The Discrete Fourier Transform - twins.ee.nctu.edu.twtwins.ee.nctu.edu.tw/courses/dsp_08/dsp8.pdfLinear Convolution Using DFT ... Method 1 – overlap and add ... The Discrete Fourier

DSP The Discrete Fourier Transform

NCTU EE 12

Linear Convolution Using DFT • Why using DFT? There are fast DFT algorithms (FFT)

• How to do it?

(1) Compute the N-point DFT of [ ]nx1 and [ ]nx2 separately

[ ]kX1 and [ ]kX 2

(2) Compute the product [ ] [ ] [ ]kXkXkX 213 =

(3) Compute the N-point IDFT of [ ]kX 3 [ ]nx3

• Problems: (a) Aliasing (b) Very long sequence

Page 13: The Discrete Fourier Transform - twins.ee.nctu.edu.twtwins.ee.nctu.edu.tw/courses/dsp_08/dsp8.pdfLinear Convolution Using DFT ... Method 1 – overlap and add ... The Discrete Fourier

DSP The Discrete Fourier Transform

NCTU EE 13

• Aliasing

[ ]nx1 , length L (nonzero values)

[ ]nx2 , length P

In order to avoid aliasing, 1−+≥ PLN (What do we mean avoid aliasing? The preceding procedure is circular convolution but we

want linear convolution. That is, [ ]nx3 equals to the linear convolution of [ ]nx1 and [ ]nx2 )

Page 14: The Discrete Fourier Transform - twins.ee.nctu.edu.twtwins.ee.nctu.edu.tw/courses/dsp_08/dsp8.pdfLinear Convolution Using DFT ... Method 1 – overlap and add ... The Discrete Fourier

DSP The Discrete Fourier Transform

NCTU EE 14

[ ]nx1 pad with zeros length N [ ]nx2 pad with zeros length N

Interpretation: (Why call it aliasing?)

[ ]kX 3 has a (time domain) bandwidth of size 1−+ PL

(That is, the nonzero values of [ ]nx3 can be at most 1−+ PL )

Therefore, [ ]kX3 should have at least 1−+ PL samples. If the sampling rate is insuf-

ficient, aliasing occurs on [ ]nx3 .

Page 15: The Discrete Fourier Transform - twins.ee.nctu.edu.twtwins.ee.nctu.edu.tw/courses/dsp_08/dsp8.pdfLinear Convolution Using DFT ... Method 1 – overlap and add ... The Discrete Fourier

DSP The Discrete Fourier Transform

NCTU EE 15

• Very long sequence (FIR filtering) Block convolution

Method 1 – overlap and add Partition the long sequence into sections of shorter length. For example, the filter impulse response [ ]nh has finite length P and the input data [ ]nx is

nearly “infinite”.

[ ] [ ] [ ] [ ]⎩⎨⎧ ≤≤+

=−= ∑∞

= otherwise 0,10 ,

whereLet 0

L-nrLnxnxrLnxnx r

rr

The system (filter) output is a linear convolution:

[ ] [ ] [ ] [ ] [ ] [ ] [ ]∑∞

=∗=−=∗=

0 where

rrrr nhnxnyrLnynhnxny

Remark: The convolution length is 1−+ PL . That is, the 1−+ PL point DFT is used. [ ]nyr has 1−+ PL data points; among them, (P-1) points should be added to the next

section.

This is called overlap-add method. (Key: The input data are partitioned into nonoverlapping sections the section outputs are

overlapped and added together.)

Page 16: The Discrete Fourier Transform - twins.ee.nctu.edu.twtwins.ee.nctu.edu.tw/courses/dsp_08/dsp8.pdfLinear Convolution Using DFT ... Method 1 – overlap and add ... The Discrete Fourier

DSP The Discrete Fourier Transform

NCTU EE 16

Method 2 – overlap and save Partition the long sequence into overlapping sections. After computing DFT and IDFT, throw away some (incorrect) outputs. For each section (length L, which is also the DFT size), we want to retain the correct data of

length ))1(( −− PL points

Let [ ]nh , length P

[ ]nxr , length L (L>P) Then, [ ]nyr contains (P-1) incorrect points at the beginning. Therefore, we divide into sections of length L but each section overlaps the preceding section

by (P-1) points. [ ] ( ) ( )[ ] 1-Ln0 ,11 ≤≤−−+−+= PPLrnxnxr

This is called overlap-save method.