dtft of a finite-length portion of the signaldsp/dsp2014/slides/course 06_2.pdf · dtft of a...

49
Approximating the Spectrum DTFT of a finite-length portion of the signal In sum, when applying DTFT only for the samples in a rectangular window of the signal, the approximation is caused by (1) frequency domain convolution with a sync function (2) aliasing Although imperfect, this is a feasible way we can do in practice for finding the spectrum of a signal.

Upload: others

Post on 15-Mar-2020

17 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Approximating the SpectrumDTFT of a finite-length portion of the signal

• In sum, when applying DTFT only for the samples in a rectangular window of the signal, the approximation is caused by

(1) frequency domain convolution with a sync function

(2) aliasing

• Although imperfect, this is a feasible way we can do in practice for finding the spectrum of a signal.

Page 2: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Approximating the SpectrumDTFT of a finite-length portion of the signal

• What can be done to further improve the performance?

• The rectangular window is applied in the above.

• It can be replaced by other better windowing functions(eg., Hann, Hamming) that will distort the shape of spectrum less.– will be investigated in the future

Page 3: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Segmenting the signal

• In the above, we only use a single segment of the signal and compute its DTFT.

• It is natural to extend this idea by separating a signal into multiple segments in time, and compute the DTFT for each segment along the time axis.

• The segments can be either non-overlapping or overlapping.

Page 4: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Spectrogram

• In this way, we can obtain a two-dimensional map(like a 2D image) – the horizontal axis is the time interval

– the vertical axis is the frequency in [-/T, /T].

– the gray level is the magnitude of DTFT of the associated segment.

• This is called spectrogram, a common way for viewing the spectral domain response for a signal in practice.– Sometimes the gray level is the magnitude square of DTFT,

depending on how it is defined.

Page 5: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Spectrogram Examples

Synthesized notes, C,D,E,F,G,A,B,CSpectrogram of Fur Elise played on a piano

Page 6: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Spectrogram Examples• DTFT range: [-𝜋, 𝜋]• Associated CFT range:

[-𝜋/𝑇𝑠 , 𝜋/𝑇𝑠] in radians.

• That is, [-𝜔𝑠/2,𝜔𝑠/2] in radians. (because 𝑤𝑠 = 2𝜋/𝑇𝑠)

• This is equivalent to [-𝑓𝑠/2,𝑓𝑠/2] in Hz.

• In the example:• 𝑓𝑠 = 8000 𝐻𝑧• 𝑓𝑠/2 = 4000 = 4 𝑘𝐻𝑧• For real-valued signal,

the magnitude is an even function. Only show the positive side [0,𝑓𝑠/2] in the spectrogram to ease the viewing

Page 7: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Further Improvement

• In the above, we compute the DTFT for a finite-length signal (of length N).

• To record the frequency domain of DTFT, we have to record a continuous function in the range of [-, ].

• However, to record exactly a continuous function in a digital device is difficult in practice.

Page 8: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

• Eg, a time-domain N-point (N=11) discrete-time signal

• Its DTFT domain is continuous

Page 9: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Another example of a finite-length x(n) and its DTFT X(ejw).Remark: in this example, we extend [-, ] to a periodic form for visualization

A finite-length signal

Magnitude spectrum of DTFT

Phase spectrum of DTFT

Page 10: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

A remark on DTFT viewing

• Though DTFT is typically viewed in [-, ], sometimes we draw all of the periods.

• Besides, because every period contains the same information, in some cases we draw [0, 2] for visualization.

• For real signal, the spectrum is an even function. Both cases [-, ] and [0, 2] can be reduced into [0, ] due to symmetry.

Page 11: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Further Improvement

• There are only N points in time domain for a finite-duration signal (i.e., time domain is an N-dimensional vector).

• We know that time and frequency domains retain the same information for signal representation.

• So, it seems to be redundant if we have to use a continuous function (containing infinite points) in the frequency domain for recording the information.

Page 12: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Further Improvement

• Can we use only a finite number points (eg., Npoints) to record the frequency domain of DTFT for a finite-duration signal?

• This leads us to the development of the fourth type of Fourier transform, Discrete Fourier Transform (DFT).

Page 13: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Discrete Fourier Transform (DFT)

• Consider both the signal and the spectrum only within one period (N-point signals both in time and frequency domains)

where , and Wn are the roots of WN=1.

DFT

IDFT(inverseDFT)

NjeW /2

Page 14: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

From Kuhn 2005

DFT in matrix form

Page 15: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

DTFT pairs (more specifically)

• Forward transform:

• Inverse transform:

where

Page 16: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

• The matrix of DFT is unitary, i.e.,

𝑫𝑵∗ 𝑫𝑵 = 𝑫𝑵𝑫𝑵

∗ = 𝑰𝑵, or 𝑫𝑵−𝟏 = 𝑫𝑵

∗ ,

where 𝑰𝑵 is the 𝑵×𝑵 identity matrix.

• That is, the inner products of two different columns of 𝑫𝑵 are zero (the columns of 𝑫𝑵 are orthogonal to each other)

𝟏

𝑵

Page 17: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

n-th Root of 1

• 𝑊𝑁𝑛 is the n-th root of the equation 𝑾𝑁 = 1.

• Eg., when n=8,

Page 18: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Visualization Illustration

• Eg., 8-point DFT

Page 19: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Relation between DFT and DTFT for finite-length signals

• Property: The frequency domain of an N-point DFT are the same as the N-point uniform samples of DTFT in [0, 2].

• Explanation:– If we repeat the length-N signal over time, we can get a

discrete-time signal that is also periodic. – It is easy to recover the original length-N signal from the

resulted periodic signal (by extracting only a single period of it). So, they contain the same ‘information’.

– The DTFT spectrum of a discrete and periodic signal is also discrete and periodic, because the time domain periodicity implies the frequency domain discretization, and vice versa.

– Hence, reconstructing the discrete-time periodic signal can also reconstruct the original length-N signal.

Page 20: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

DTFT of a discrete and periodic signal

• The DTFT spectrum of a discrete and periodic signal is also discrete and periodic.

• Note that the DTFT spectrum of the periodic signal is the N-point uniform samples of original continuous DTFT spectrum.

A discrete-time periodic signal

Its magnitude spectrum (sampled)

Its phase spectrum (sampled)

Page 21: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Relation between DFT and DTFT for finite-length signals

• IDFT give us an algorithm to reconstruct the N-length discrete-time signal.

• Question: Can we reconstruct the DTFT spectrum (continuous in w) from the N-length spectrum of DFT?

• Since the N-length signal can be exactly recovered from both the DFT and the DTFT spectra, we expect that the DTFT spectrum (that is continuous in [0, 2]) can be exactly reconstructed by the DFT spectrum (that is discrete).

Page 22: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Reconstruct DTFT from DFT(when the sequence is finite-length)

By substituting the inverse DFT into the x(n), we have

a geometric sequence

Continuous DTFT spectrum

Inverse DFT of N points

Page 23: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

By applying the geometric-sequence formula

magnitude

phase

Page 24: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

So

The reconstruction formulaFrom X(k), the spectrum of DFT , we can reconstruct the spectrum of DTFT, X(ejw) by the above interpolation.

Hence, instead of computing the DTFT of a finite-duration signal directly, we always use DFT for the computation, and the DTFT spectrum can be exactly reconstructed for any w.

Another way to interpolate X(ejw) from X(k) is zero-padding that will be shown below.

Dirichlet Kernel

Page 25: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Definition of DFT in Boaz Porat’s Book

Remark

• There could be different notations from different articles and books.

• The Fourier transform is referred to as DTFT below.

DTFT

Page 26: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Zero padding

• In the above, we have introduced how to reconstruct the DTFT spectrum of an length-N signal from the DFT spectrum of the same length-N signal.

• Sometimes our purpose is for visualization or efficient maximum finding. The N samples of the DTFT spectrum is too few. We often like to see the M-point uniform samples of the DTFT of the length-N signal (with M>N).

• In practice, we can use a simple technique called zero-padding technique to achieve this purpose, which complement M-N zeros in the end of the original length-N sequence and then performing DFT. Then, the obtained M-point DFT spectrum is just the M-point uniform samples for the DTFT of the length-N signal.

Page 27: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples
Page 28: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples
Page 29: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Fast Fourier Transform (FFT)

An important characteristic of DFT is that it can be computed very fast

DFT pairs:

WN = ej2/N is a root of the equation WN=1.

It requires N2 complex multiplications and (N1)N complex additions for direct computation.

1

0

1...,1,0 ,][][N

n

kn

N NkWnxkX

1

0

1...,1,0 ,][1

][N

k

kn

N NnWkXN

nx

Page 30: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Decimation-in-time FFT algorithm

Most conveniently illustrated by considering the special case of N an integer power of 2, i.e, N=2v.

Since N is an even integer, we can consider computing X[k] by separating x[n] into two (N/2)-point sequence consisting of the even numbered point in x[n] and the odd-numbered points in x[n].

dd

][][][on

nk

N

evenn

nk

N WnxWnxkX

Page 31: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Decimation-in-time FFT algorithm

With the substitution of variable n=2r for n even and n=2r+1 for n odd:

By the key property:

We have

1)2/(

0

)12(1)2/(

0

2 ]12[]2[][N

r

kr

N

N

r

rk

N WrxWrxkX

( /2) 1 ( /2) 12 2

0 0

[ ] [2 ]( ) [2 1]( )N N

rk k rk

N N N

r r

X k x r W W x r W

2/

)2//(2)/2(22

N

NjNj

N WeeW

( /2) 1 ( /2) 1

/2 /2

0 0

[2 ]( ) [2 1]( )N N

rk k rk

N N N

r r

x r W W x r W

Page 32: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

In sum,

• Both G[k] and H[k] can be computed by (N/2)-point DFT

• G[k]: the (N/2)-point DFT of the even numbered points of the original sequence

• H(k): the (N/2)-point DFT of the odd-numbered point of the original sequence.

• Although the index ranges over N values, k = 0, 1, …, N-1, they must be computed only for k between 0 and (N/2)-1, since G[k] and H[k] are each periodic in k with period N/2.

1,...,1,0 ],[][ NkkHWkG k

N

( /2) 1 ( /2) 1

/2 /2

0 0

[ ] [2 ]( ) [2 1]( )N N

rk k rk

N N N

r r

X k x r W W x r W

Page 33: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Decomposing N-point DFT into two (N/2)-point DFT for the case of N=8

Page 34: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

We can further decompose the (N/2)-point DFT into two (N/4)-point DFTs. For example, the upper half of the previous diagram can be decomposed as

Page 35: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Hence, the 8-point DFT can be obtained by the following diagram with four 2-point DFTs.

Page 36: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Flow graph of a 2-point DFT

Finally, each 2-point DFT can be implemented by the following signal-flow graph, where no multiplications are needed.

Page 37: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Flow graph of complete decimation-in-time decomposition of an 8-point DFT.

Page 38: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

In each stage of the decimation-in-time FFT algorithm, there are a basic structure called the butterfly computation:

The butterfly computation can be simplified as follows:

Flow graph of a basic butterfly computation in FFT.

Simplified butterfly computation.

][][][

][][][

11

11

qXWpXqX

qXWpXpX

m

r

Nmm

m

r

Nmm

Page 39: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Flow graph of 8-point FFT using the simplified butterfly computation

Page 40: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

• In the above, we have introduced the decimation-in-time algorithm of FFT.

• Here, we assume that N is the power of 2. For N=2v, it requires v=log2N stages of computation.

• The number of complex multiplications and additions required was N+N+…N = Nv = N log2N.

Page 41: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

• When N is not the power of 2, we can apply the same principle that were applied in the power-of-2 case when N is a composite integer. For example, if N=RQ, it is possible to express an N-point DFT as either the sum of R Q-point DFTs or as the sum of Q R-point DFTs.

• The FFT algorithm of power-of-two is also called the Cooley-Tukey algorithm since it was first proposed by them.

Page 42: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Decimation-in-frequency FFT algorithm

The decimation-in-time FFT algorithms are all based on structuring the DFT computation by forming smaller and smaller subsequences of the input sequence x[n]. Alternatively, we can consider dividing the output sequence X[k] into smaller and smaller subsequences in the same manner.

The even-numbered frequency samples are

So,

1,...,1,0 ][][1

0

NkWnxkXN

n

nk

N

1

)2/(

)2(1)2/(

0

)2(1

0

)2( ][][][]2[N

Nn

rn

N

N

n

rn

N

N

n

rn

N WnxWnxWnxrX

1)2/(

0

))2/((21)2/(

0

2 )]2/([][]2[N

n

Nnr

N

N

n

nr

N WNnxWnxrX

Page 43: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Since

and , we have 𝑊𝑁2𝑛𝑟 = 𝑊𝑁/2

𝑛𝑟 .

Then, both the first half and last half share the same multiplication term, 𝑊𝑁/2

𝑛𝑟 , and so

The above equation is the (N/2)-point DFT of the (N/2)-point sequence obtained by adding the first and the last half of the input sequence.

Analogical meaning: Adding the two halves of the input sequence represents time aliasing, consistent with the fact that in computing only the even-number frequency samples, we are sub-sampling the Fourier transform of x[n].

nr

N

rN

N

nr

N

Nnr

N WWWW 22)]2/([2

2/

2

NN WW

1)2/(,...,1,0 )])2/([][(]2[1)2/(

0

2/

NrWNnxnxrXN

n

nr

N

Page 44: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

We now consider obtaining the odd-numbered frequency points:

Since

1

)2/(

)12(1)2/(

0

)12(1

0

)12( ][][][]12[N

Nn

rn

N

N

n

rn

N

N

n

rn

N WnxWnxWnxrX

)12(1)2/(

0

)12(1)2/(

0

2/

)12(1)2/(

0

2/

)12(1)2/(

0

)12)(2/(

1)2/(

0

)12)(2/(1

2/

)12(

)]2/([

)]2/([

)]2/([

)]2/([

)]2/([][

rn

N

N

n

rn

N

N

n

N

N

rn

N

N

n

NNr

N

rn

N

N

n

rN

N

N

n

rNn

N

N

Nn

rn

N

WNnx

WNnxW

WNnxW

WNnxW

WNnxWnx

Page 45: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

We obtain

The above equation is the (N/2)-point DFT of the sequence obtained by subtracting the second half of the input sequence from the first half and multiplying the resulting sequence by WN

n.

Let g[n] = x[n]+x[n+N/2] and h[n] = x[n]x[x+N/2], the DFT can be computed by forming the sequences g[n] and h[n], then computing h[n]WN

n, and finally computing the (N/2)-point DFTs of these two sequences.

1)2/(,...,1,0 ])2/[][(

])2/[][(]12[

2/

1)2/(

0

1)2/(

0

)12(

NrWWNnxnx

WNnxnxrX

nr

N

N

n

n

N

N

n

rn

N

Page 46: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Flow graph of decimation-in-frequency decomposition of an N-point DFT (N=8).

Page 47: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Recursively, we can further decompose the (N/2)-point DFT into smaller substructures:

Page 48: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Finally, we have

Page 49: DTFT of a finite-length portion of the signaldsp/dsp2014/slides/Course 06_2.pdf · DTFT of a finite-length portion of the signal •In sum, when applying DTFT only for the samples

Butterfly structure for decimation-in-frequency FFT algorithm:

The decimation-in-frequency FFT algorithm also has the computation complexity of O(N log2N)