# CE 40763 Digital Signal Processing Fall 1992 Discrete Fourier Transform (DFT)

description

### Transcript of CE 40763 Digital Signal Processing Fall 1992 Discrete Fourier Transform (DFT)

CE 40763Digital Signal Processing

Fall 1992

Discrete Fourier Transform (DFT)Hossein Sameti

Department of Computer Engineering Sharif University of Technology

2

Motivation The DTFT is defined using an infinite sum over a

discrete time signal and yields a continuous function X(ω)◦ not very useful because the outcome cannot be stored on

a PC. Now introduce the Discrete Fourier Transform

(DFT), which is discrete and can be stored on a PC.

We will show that the DFT yields a sampled version of the DTFT.

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Review of Transforms

3

dtetxtxCTFTX tj)()}({)(

n

njenxnxDTFTX )()}({)(

)(txC.

)(nxD.

C.

C.

n

nznxnxzzX )()}({)()(nxD. Complex

Inf. orFinite

1

0

2~~~)()}({)(

N

n

Nknj

enxnxDFSkX

)(~

nxD. Int.

periodicperiodic

1

0

2

)()}({)(N

n

Nknj

enxnxDFTkX

)(nxD.

Int.finite finite

Review of Transforms

4

dtetxtxCTFTX tj)()}({)(

n

njenxnxDTFTX )()}({)(

)(tx

)(nx

n

nznxnxzzX )()}({)()(nx

1

0

2~~~)()}({)(

N

n

Nknj

enxnxDFSkX

)(~

nx

1

0

2

)()}({)(N

n

Nknj

enxnxDFTkX

)(nx

Discrete Fourier Series (DFS)

5

periodNkNnxnx :)()(~~

• Decompose in terms of complex exponentials that are periodic with period N.

)(~

nx

• How many exponentials? N

1,...,1,0)(2

Nkene Nknj

k

1

0

2~)(1)(

N

k

Nknj

ekXN

nx

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Discrete Fourier Series (DFS)

6

1,...,1,0)(2

Nkene Nknj

k

Exponentials that are periodic with period N.

)()( nene rNkk arbitrary integer

* Proof:

NnrNkj

rNk ene)(2

)(

NrnNj

Nknj

rNk eene 22

.)(

)()(2

neene kN

knj

rNk

1

....)()()( 20 nenene NN....)()()( 1211 nenene NN

7

Discrete Fourier Series (DFS)

1

0

2~)(1)(

N

k

Nknj

ekXN

nx

How to find X(k)?

Answer:

1

0

2~)()(

N

n

Nknj

enxkX

Proof : substitute X(k) in the first equation.

• It can also easily be shown that X(k) is periodic with period N:

)()( rNkXkX arbitrary integer

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

DFS Pairs

8

Analysis:

1

0

2~~)()(

N

n

Nknj

enxkX

Synthesis:

1

0

2~~)(1)(

N

k

Nknj

ekXN

nx

Periodic N pt.seq. in time domain

Periodic N pt.seq. in freq. domain

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Example

9

n0

1

rrNnnx )()(

~

1 1

N

1

0

2~~)()(

N

nN

knj

enxkX

1

0

2

)(N

nN

knj

en

Nkj

e)0(2

1

n0

1 1

N

…1

…

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Example (cont.)

10

rrNnnx )()(

~

1

0

2~~)()(

N

nN

knj

enxkX

1

0

2

)(N

nN

knj

en

Nkj

e)0(2

1

1

0

2~~)(1)(

N

k

Nknj

ekXN

nx

1

0

21 N

kN

knj

eN

(eq.1)

(eq.2)

(eq.1) & (eq.2)

rrNn )(

1

0

21 N

kN

knj

eN

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Shift property:

Periodic convolution:

Properties of DFS

11

)(~

kX)(~

nx

)(~2 0

kXe Nkn

j

)( 0

~nnx

3

~

2

~

1

~xxx

Period N

1

02

~

1

~)()(

N

mmnxmx

)()()( 3~

2~

1~

kXkXkX Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Periodic convolution - Example

12Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

13

In the list of properties:

Properties of DFS

1,...,1,0)(2

Nkene Nknj

k

=

=

Where:

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Properties of DFS

14Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Properties of DFS

15Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Discrete Fourier Transform

16

)(kX)(nx

N pt. N pt.

DFTN pt. N pt.

DFT

DTFT

DFSHossein Sameti, Dept. of Computer Eng., Sharif University of Technology

1) Start with a finite-length seq. x(n) with N points (n=0,1,…, N-1).

2) Make x(n) periodic with period N to get

Deriving DFT from DFS

17

)(~

nx

)()()(~

nRnxnx N Extracts one period of )(~

nx

otherwise

NnnRN 0

1,...,1,01)(

rrNnxnx )()(

~

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

3) Take DFS of 4) Take one period of to get DFT of x(n):

18

Deriving DFT from DFS (cont.))(

~nx )(

~kX

)(~

kX )(kX

)()()(~

kRkXkX N

)(nx )(~

nx )(~

kX )(kX

N pt. N pt.N pt.periodic

N pt.periodic

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Example

19

n0 1 2 3

12

3

1

)(nx

n0 1 2 3

12

3

1

)(~

nx

k0 1 2 3

k0 1 2 3

)(~

kX

)(kX

12

3

1 12

3

1

Definition of DFT:

Discrete Fourier Transform

20

otherwise

NkenxkXN

n

Nknj

0

0)()(1

0

2

N pt. DFT of x(n)

otherwise

NnekXNnx

N

k

Nknj

0

0)(1)(

1

0

2

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Example

21

otherwise

nnx

0

501)( ?)( kX

otherwise

kenxkX n

knj

0

50)()(4

0

52

otherwise

ke

ekX kj

kj

0

501

1)( 5

2

2

otherwise

kkX

005

)(

Example, cont’d

Mehrdad Fatourechi, Electrical and Computer Engineering, University of

British Columbia, Summer 201122

Relationship between DFT and DTFT

23

otherwise

NkenxkXN

n

Nknj

0

0)()(1

0

2

n

njenxX )()(

otherwise

NkXkX N

k

0

0)()(

2

DFT thus consists of equally-spaced samples of DTFT.

1

0)(

N

n

njenx

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

24

Relationship between DFT and DTFT

)(X

3

8 pt. sequence 8 pt. DFT

7,...,1,08

2 kk

3 2

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

M pt. DFT of N pt. Signal

25

otherwise

NkXkX N

k

0

0)()(

2

So far we calculated the N pt. DFT of a seq. x(n) with N non-zero values:

Suppose we pad this N pt. seq. with (M-N) zeros to get a sequence with length M.

n0 1 2 3

12

3

1

)(nx We can now take an M-pt. DFT of the signal x(n)

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

26

M pt. DFT of N pt. Signal

otherwise

MkenxkXM

n

Mknj

0

0)()(1

0

2

DFTN pt. M pt.

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Example

27

4 pt. DFT:

otherwise

kenxkX n

knj

0

40)()(3

0

42

6 pt. DFT:

otherwise

kenxkX n

knj

0

60)()(5

0

62

n0 1 2 3

12

3

1

)(nx

8 pt. DFT:

otherwise

kenxkX n

knj

0

80)()(7

0

82

100 pt. DFT:

otherwise

kenxkX n

knj

0

1000)()(99

0

1002

How are these related to each other?

28

M pt. DFT of N pt. Signal

)(X

20

Going from N pt. to 2N pt. DFT

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

29

M pt. DFT of N pt. Signal

N pt.DFT

N pt. seq. N pt.

2N pt.DFTN pt. seq.

padded with N zeros

2N pt.

What is the minimum number of N needed to recover x(n)?

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Assume y(n) is a signal of finite or infinite extent.

Problem Statement

30

)}({)( nyDTFTY • Sample at N equally-spaced points.)(Y

)()( 2 kXYN

k

N pt. sequence.

)()}({ nxkXIDFT N pt. sequence.

What is the relationship between x(n) and y(n)?

What happens if N is larger , equal or less than the length of y(n)?

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

We start with x(n) and find its relationship with y(n):

Solution to the Problem Statement

31

otherwise

NnekXNnx

N

k

Nknj

0

0)(1)(

1

0

2

otherwise

NneemyNnx

N

k

Nknj

m

Nkmj

0

0))((1)(

1

0

22

)()( 2 kXYN

k

Change the order of summation:

otherwise

NneN

mynxN

k

Nnmkj

m0

01)()(1

0

)(2

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

32

Solution to the Problem Statement

However, we have shown that:

otherwise

NneN

mynxN

k

Nnmkj

m0

01)()(1

0

)(2

1

0

2~)(.11)(

N

k r

Nknj

rNneN

nx

rrNnnf )()(

rrNmnmnf )()(

otherwise

Nnmnfmynx m0

0)()()(Convolution with train of delta functions

101)(~

NkkX

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

33

Solution to the Problem Statement

otherwise

NnrNnynx r0

0)()(

One period of the replicated version of y(n)

• Examples

If we sample at a sampling rate that is higher than the number of points in y(n), we should be able to recover y(n).

)(Y

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Shift property:

Properties of DFT

34

)()( kXnx DFT N pt. seq.

Nkn

jDFT ekXnnx02

0 )()(

Nk 0

Nk 0

The above relationship is not correct, because of the definition of DFT.

The signal should only be non-zero for the first N points.

Nkn

jDFTN ekXnRnnx

02

0

~)()()(

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

35

In the list of properties:

Properties of DFT

1,...,1,0)(2

Nkene Nknj

k

= , =

where:

)()(]))[(( 0

~

0 nRnnxnnx NN

otherwise

NnnRN 0

1,...,1,01)(

and

where:

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

36

Summery of Properties of DFT

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

37

Summery of Properties of DFT

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Using DFT to calculate linear convolution

38Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

We are familiar with, “linear convolution”. Question: Can DFT be used for calculating the linear

convolution? The answer is: NO! (at least not in its current format) We now examine how DFT can be applied in order to

calculate linear convolution.

Convolution

39Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Definitions of convolution

40

3

~

2

~

1

~xxx

1

02

~

1

~)()(

N

mmnxmx

• Linear convolution:

)()()( 321 nxnxnx k

knxkxnx )()()( 213

Application in the analysis of LTI systems

• Periodic convolution:

A seq. with period N

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Definitions of convolution(cont.)

41

321 xxx • Circular convolution:

N pt. seq.

• Circular convolution is closely related to periodic convolution.

)()].()([)()()( 2

~

1

~

213 nRnxnxnxnxnx N

)().()( 213 kXkXkX

N pt. DFT of x1N pt. DFT of x2N pt. DFT of x3

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Example: Circular Convolution

42

)1()(1 nnx

seq.pt.:)(2 NnxCircular convolution?

Make an N pt. seq.)(1 nx

Nn

nn

nx10

11100

)(1

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

43

Example: Circular Convolution

Circular Convolution & DFT

44

)()].()([)()()( 2

~

1

~

213 nRnxnxnxnxnx N

We know from DFS properties:

3

~

2

~

1

~xxx )()()( 3

~2

~1

~kXkXkX

)}({)( 1

~

1

~nxDFSkX )}({)( 2

~

2

~nxDFSkX )}({)( 3

~

3

~nxDFSkX

)()()()()( 3~

2~

1~

kRkXkRkXkX NN

)()().( 321 kXkXkX Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

45

Circular Convolution & DFT

)()].()([)()()( 2

~

1

~

213 nRnxnxnxnxnx N

)()().( 321 kXkXkX

If we multiply the DFTs of two N pt. sequences, we get the DFT of their circular convolution and not the DFT of their linear convolution.

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Example : Circular Convolution

46

otherwise

Lnnxnx

0

01)()( 21

Calculate N pt. circular convolution of x1 and x2 for the following two cases of N:1) N=L2) N=2L

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

47

Case 1: N=L

otherwise

Lnnx

0

101)(1

N pt. DFT of x1

otherwise

LkenxkXL

n

Lknj

0

10)()(1

0

2

otherwise

kLkXkX

00

)()( 21

)().()( 213 kXkXkX

otherwise

kL0

02

otherwise

LnLnx

010

)(3

IDFT

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

48

Case 1: N=L

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

49

Case 2: N=2L• Pad each signal with L extra zeros to get an 2L pt. seq.:

N=2L pt. DFT of x1

otherwise

LkenxkXL

n

Lknj

0

120)()(12

0

22

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

50

Case 2: N=2L

Same as linear convolution!!

Our hypothesis is that if we pad two DT signals with enough zeros so that its length becomes N, we can use DFT to calculate linear convolution.

Using DFT to Calculate linear Convolution

51

)(1 nx L pt. seq. LN

)(2 nx P pt. seq. PN

)(*)()( 213 nxnxnx Using DFTGoal: calculate

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

52

n

njenxnxDTFTX )()}({)(

Using DFT to Calculate linear Convolution

)(*)()( 213 nxnxnx )()()( 213 XXX

To get DFT, we have to sample the above DTFT at N equally-spaced points:

otherwise

NnrNnxr0

0)(3

NkXkY

23 )()(

)}({ kYIDFTSolution to the problem statement

(Eq.1)

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

53

Using DFT to Calculate linear Convolution

Nk

Nk

Nk XXXkY

222123 )()()()(

N pt. DFT of x1 N pt. DFT of x2

otherwise

NnrNnxr0

0)(3

(Eq.2))()()}({ 21 nxnxkYIDFT

Circular convolution

(Eq.1)

(Eq.2))()( 21 nxnx

Replicated version of the linear convolution

On the other hand, we know that:

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

In other words, the N pt. circular convolution of two DT signals is the same as their linear convolution, if we make the result of linear convolution periodic with period N and extract one period.

54

Using DFT to Calculate linear Convolution

1)(3 PLnx

1 PLNTo avoid aliasing:

We can thus use DFT in order to calculate the linear convolution of two sequences!

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

1) Start with

Algorithm for calculating linear convolution using DFT

55

)(1 nx L pt. seq.

)(2 nx P pt. seq.

3) Pad with N-L zeros to get N points.4) Pad with N-P zeros to get N points.

)(1 nx)(2 nx

5) Calculate the N pt. DFTs of the above two sequences and multiply them together.6) Calculate IDFT of the resulting N pt. sequence.

2) Choose 1 PLN

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Using DFT for linear filtering when one sequence is very long

56

h(n))(nx )(ny

A very long sequence

An FIR filter with a limited number of taps (P)

• Examples of this situation?

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

57

Using DFT for linear filtering when one sequence is very long

Solution to the problem

Overlap - add

Main idea: using the following property:)(*)()(*)()(*)]()([ 2121 nhnxnhnxnhnxnx

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Segment the long sequence into non-overlapping chunks of data with the length of L.

Convolve each chunk with h(n) to get (L+P-1) new points.

Add the results of the convolution of all chunks to get the final answer.

Overlap- add method

58Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

59

Overlap- add method- Example

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

60

Overlap- add method- Example

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

61

Overlap- add method- Example

Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology

Discussed DFS and DFT and examined the relationship between DFT and DTFT

Showed how DFT can be used for calculating convolution sum.

Next: Fast Fourier Transform

Summary

62Hossein Sameti, Dept. of Computer Eng., Sharif University of Technology