<<

Lecture 7 - The Discrete Transform

7.1 The DFT

The Discrete (DFT) is the equivalent of the continuous Fourier

Transform for signals known only at instants separated by sample times ¡ (i.e.

a finite of data).

Let ¢¤£¦¥¨§ be the continuous signal which is the source of the data. Let samples

  be denoted ¢ ©  ¢¤© ¢¤©  ¢¤©  ¢ © .

The Fourier Transform of the original signal, ¢¤£¦¥¨§ , would be

(*)

+/102,3

£"!$#%§'& ¢¤£,¥¨§.- ¥

)

+ ¢¤©45 We could regard each sample ¢¤©  as an impulse having area . Then, since the

integrand exists only at the sample points:

(98;:

+=<>;?

+/A02B3

£6!$#%§7& ¢¤£¦¥¨§¨- ¥

@



8;:

+/¨EGF +/10H?IF F +/10J¨?IF +/A0 +=<>;?

& ¢¤©C  D- ¢¤© D-  ¢¤©  D- ¢¤£ H§¨-

:

+=<

L

+/10J¨? ¢¤©  D-

ie. £"!$#%§K&

JNMOE

We could in principle evaluate this for any # , but with only data points to start with, only final outputs will be significant.

You may remember that the continuous Fourier transform could be evaluated

QP @ over a finite interval (usually the fundamental period ¡ ) rather than from to

82 P

F if the was periodic. Similarly, since there are only a finite number

§

of input data points, the DFT treats the data as if it were periodic (i.e. ¢¤£ to

 S

H§ ¢¤£ § ¢¤£ H§ ¢¤£ is the same as to .) Hence the sequence shown below in Fig. 7.1(a) is considered to be one period of the periodic sequence in plot (b).

(a) 1

0.8

0.6

0.4

0.2

0 0 1 2 3 4 5 6 7 8 9 10 11

(b) 1

0.8

0.6

0.4

0.2

0

0 5 10 15 20 25 30

Figure 7.1: (a) Sequence of &TU samples. (b) implicit periodicity in DFT.

Since the treats the data as if it were periodic, we evaluate the

< :

DFT equation for the fundamental (one cycle per sequence, ? Hz,

VXW :

? rad/sec.) and its harmonics (not forgetting the d.c. component (or average) at

#Y&Z ).



\ \ \ H\

 ^  £ U§

i.e. set #Y&Z [

¡ ¡S] ¡ ]`_ ¡S]

or, in general

:

+=<

L

S

+/$bdc J

egf

© & ¢¤©  D- £ &Z ih H§

_ _ JaMOE

83

¢¤© 

© is the Discrete Fourier Transform of the sequence . _

We may write this equation in form as:

m j

n k

jk n mn mn jk k

     

k n n n k k

V

:

©C  ¢¤©C 

+=<

k n n n k k

 p p prq Tp

k n n n k k

V V

:

© ¢¤©

+

kl n n n kl k

 p pts pru Tp

n kl

:

©  ¢¤© 

+

&

 pvq p prw Tp q

. u . o . o . .

. o

 S

.

V

: : :

¢¤©  © 

+=< + +

q

 p p p  p

V



:

&Zxy[z{£ !\}| § p &Zp &~ where p and etc. .

DFT – example

Let the continuous signal be

@

ˆ‡

F FŠ‰

¢¤£¦¥¨§K&  ¤„ $†U£H\¥ § „ ‹†OŒ\¥

€‚ƒ € ‚ ƒ

€ ‚ ƒ dc 1Hz 2Hz

10

8

6

4

2

0

−2

−4 0 1 2 3 4 5 6 7 8 9 10

Figure 7.2: Example signal for DFT.

q

¢ ¥Ž&r ¥Ž& Let us sample ¢¤£¦¥¨§ at 4 times per second (ie. = 4Hz) from to . The

values of the discrete samples are given by: s

W

“‡

@

F F”‰

J

V

$‘’5£  § •$’\{ ¥¤&r¡–—&

¢¤©  &t by putting s

84

‰

¢¤© &šŒ ¢¤©  ›&t™ ¢¤© &Z £ &ZŒR§

i.e. ¢ ©  ˜&t™ , , , ,

L L

q q



+/c J J

f f

b

¢¤©  d- & ¢¤©  A£ !§ &

Therefore ©

_

E

JNMOE

jk mn jk mn jk mn jk mn

l l l l

k n k n k n k n

©C      ¢¤©C  $

  

©  !  ! ¢¤© !RŒ

 

& &

o o o o

©      ¢¤©  H

 

‰ ‰

©  !  ! ¢¤© !RŒ

The magnitude of the DFT coefficients is shown below in Fig. 7.3.

20

15

10 |F[n]|

5

0 0 1 2 3 f (Hz)

Figure 7.3: DFT of four point sequence.

Inverse Discrete Fourier Transform

The inverse transform of

:

+=<

L

J +/bdc

egf

© & ¢¤©  d-

_ JaMOE

85

is

:

+=<

L



J /

bdc

ef

¢ ©4 & © D-Uœ

_

MOE

f <

i.e. the inverse matrix is : times the of the original (symmet-

ric) matrix.

¢ ©4

Note that the © coefficients are complex. We can assume that the values are real (this is the_ simplest case; there are situations (e.g. radar) in which two

o inputs, at each  , are treated as a complex pair, since they are the outputs from ‡ o

and demodulators).

ž

©

In the process of taking the inverse transform the terms © and (re-

:

_ _ V member that the spectrum is symmetrical about ) combine to produce  fre-

quency components, only one of which is considered to be valid (the one at the

VXW

: V

lower of the two , ? Hz where ; the higher frequency

:

_*] _ Ÿ

component is at an “ frequency” ( V )).

_Š¡

¢

© ©

From the inverse transform formula, the contribution to ¢¤©  of and _

is: _



 8;:

/ / + >"J¥ J¤F

bdc bdc

f egf e

¢ ©  & © D- © D- š£

f (7.2)

_ _

:

+=<

L

S

8:

+/bdc + >¦J

f e

 © & ¢¤©  D-

For all ¢¤©  real

_

JaMOE

VXW

8:

+/bdc + >¦J +/ J /$bdc¨§ J /$bdc J

e f e egf

œ œ

- & - - &Z-

‚ ƒ But €

1 for all 

S ª©

© £ §

i.e. & (i.e. the complex conjugate)

_ _

86

¢ © 

Substituting into the Equation for f above gives,

VXW

©



bdc bdc

+/ J¤F JH¥ / J /

egf egf

£ §.- ¢ ©4 & - &T © d- £

f since

_ _

š­¦®

 \ \

¥ ¥ ¥

¢ ©  ›&  © †¨¯6°  © „‘ ‹†

£ £«¬£

ie. f

_ _ _ _

 \

F”²$³¨´ ¥

¢ ©  & §¨¡ £ © d§ © „‘ ‹† £

T± ± £

or f

_ _ _

¡

VXW V

f

© 

± ±

: :

i.e. a sampled sinewave at ? Hz, of magnitude

_

For the special case of , ©  Ž&S¶·¢ ©4 (i.e. sum of all samples) and the

<

_

E

©C  ¢ ©4 ¢ ©  ¤& ©  —& ¢¤©  ¤& contribution of to is : average of d.c. compo- nent.

Interpretation of example

V

< E

©C  ›&r$ ©C  & &r

1. implies a d.c. value of : (as expected)

s

 ª©

‰

!RŒ¸& ©

2. © {& implies a fundamental component of peak

V V

¹‡

²³¨´ o

©¦‘ & Œª&r © ›&

± ±

: with given by

]

s

ˆ‡ Y‡ \

\ o o

¡ §¤&tK„‘ ‹†U£  §

i.e. ¤„ ‹†£ (as expected)

¡ 

S

:

V

£ &

3. ©  &ºH – no other component here) and this implies a _

component _

V W

 

/ J / J ‰

bdc

e¼»

V

©  D- & ©4H d- & ‘’\{ ¢ ©  &

(as expected)

Œ  since †¨¯D°\{i&t for all

87 6

5

4

3 3/sqrt(2) |F[n]| 2 sqrt(2)

1

0 0 1 2 3 f (Hz)

Figure 7.4: DFT of four point signal.

Thus, the conventional way of displaying a spectrum is not as shown in Fig. 7.3

but as shown in Fig. 7.4 (obviously, the information content is the same):

&½U RŒ

In typical applications, is much greater than Π; for example, for ,

 

‰ ‰

© U R ^ ^$ 

has U ‹Œ components, but are the complex conjugates of ,

V V

<¦À

_

 Â

V V V

V V

¾¿ ¾¿ à ¾¿

leaving

V

s s{Á Á sGÁ Á

< À

<

Â

V

V

¾¿ Ã

ponents and

s

:

V

& §

frequency £ .

_

À À

b

f f

¾¿ ¾¿ :

Most computer programmes evaluate : (or for the power spectral den-

Á Á Á

sity) which gives the correct “shape” Á for the spectrum, except for the values at

: V

&Z and . _

7.2 Discrete Fourier Transform Errors

To what degree does the DFT approximate the Fourier transform of the underlying the data? Clearly the DFT is only an approximation since it provides only for a finite set of frequencies. But how correct are these discrete values themselves? There are two main types of DFT errors: aliasing and “leakage”:

88 7.2.1 Aliasing This is another manifestation of the phenomenon which we have now encountered several times. If the initial samples are not sufficiently closely spaced to represent high-frequency components present in the underlying function, then the DFT val- ues will be corrupted by aliasing. As before, the solution is either to increase the sampling rate (if possible) or to pre-filter the signal in order to minimise its high- frequency spectral content.

7.2.2 Leakage

Recall that the continuous Fourier transform of a periodic waveform requires the

P P integration to be performed over the interval - to F or over an number of cycles of the waveform. If we attempt to complete the DFT over a non-integer number of cycles of the input signal, then we might expect the transform to be corrupted in some way. This is indeed the case, as will now be shown.

Consider the case of an input signal which is a sinusoid with a fractional num-

:

V &

ber of cycles in the data samples. The DFT for this case (for &Ä to ) _ is shown below in 7.5. _

8

6

4 |F[n]|

2

0 0 2 4 6 8 freq

Figure 7.5: Leakage.

We might have expected the DFT to give an output at just the quantised frequen-

89 cies either side of the true frequency. This certainly does happen but we also find non-zero outputs at all other frequencies. This smearing effect, which is known as leakage, arises because we are effectively calculating the for the waveform in Fig. 7.6, which has major discontinuities, hence other frequency components.

1

0.5

0

−0.5

−1 0 5 10 15 20 25 30 35 40 45 50

Figure 7.6: Leakage. The repeating waveform has discontinuities.

Most of real data are much more complicated than the sinusoidal se- quences that we have so far considered and so it will not be possible to avoid in- troducing discontinuities when using a finite number of points from the sequence in order to calculate the DFT. The solution is to use one of the window functions which we encountered in the design of FIR filters (e.g. the Hamming or Hanning windows). These window functions taper the samples towards zero values at both endpoints, and so there is no discontinuity (or very little, in the case of the Hanning window) with a hypothetical next period. Hence the leakage of spectral content away from its correct location is much reduced, as in Fig 7.7.

(a) (b) 7 5

6 4 5

4 3

3 2 2 1 1

0 0 0 2 4 6 8 0 2 4 6 8

Figure 7.7: Leakage is reduced using a Hanning window.

90 7.3 The

The time taken to evaluate a DFT on a digital computer depends principally on the

number of multiplications involved, since these are the slowest operations. With V

the DFT, this number is directly related to (matrix multiplication of a vector), where is the length of the transform. For most problems, is chosen to be at least 256 in order to get a reasonable approximation for the spectrum of the sequence under consideration – hence computational speed becomes a major con- sideration.

Highly efficient computer for estimating Discrete Fourier Trans- forms have been developed since the mid-60’s. These are known as Fast Fourier Transform (FFT) algorithms and they rely on the fact that the standard DFT in-

volves a lot of redundant calculations:

: :

+=< +=<

L L

+/ J J

bdc

f f

e

:

¢¤©  D- ¢¤©  dp ›& © &

Re-writing © as

_ _

JaMOE JNMOE

J

f : it is easy to realise that the same values of p are calculated many times as the

computation proceeds. Firstly, the integer  repeats for different com-

J

_

f

: p binations of  and ; secondly, is a with only distinct

values. _

For example, consider &9™ (the FFT is simplest by far if is an power

of 2)



 !

< +/ +/

bdc

Æ

Å

È

s

p &t- &t- & &ZÉ= 

ÃXÇ say



V

   © 

É & ! ÉRq& !5Éi& É É & 

Then s

Å

 ©

É & É É &Ê! É5Ë%&Ê!5ÉÌ&9É É &~

u Ã

From the above, it can be seen that:

91



E

Å Å

pts & p



<

Å Å

& p p

Ã

V



Å Å

p & p

u



Å Å

pvË & pvq

Also, if  falls outside the range 0-7, we still get one of the above values:

_

Å

Å

q q q q

sŽÎ

&º£É § É &tÉ &tÉ &t i&rÍ^ p Ã

eg. if and à _

7.3.1 Decimation-in-time

Let us begin by splitting the single summation over samples into 2 summations,

:

V 

each with samples, one for  even and the other for odd.

J J‘+=<

V V

 ÏS& 

Substitute ÏS& for even and for odd and write:

e e

+=< +=<

b b

V

L L

V

Ð

8

Ð

<>

f

F F

f

œ

:

¢ ©4ϸ dp ¢¤© Ï  dp © &

:

_

Ð Ð

MOE MOE

Ð

+/

bdc

e

V V

f

Ð Ð Ð

8

> +/

bdc

f f f

e

e

b :

p &9- &rp

Note that &t-

b

e e

+=< +=<

b b

L L

Ð Ð Ð

F F

f f

e e

:

¢ ©4ϸ dp ¢¤© Ï  dp © &

Therefore p

_

b b

Ð Ð

MOE MOE

Ð

F

:iÓ

&tÑÒ© p ©

ie. ©

_ _ _

:

V

Thus the -point DFT © can be obtained from two -point transforms,

_

Ó

©

one on even input data, ÑÒ© , and one on odd input data, . Although the fre-

:

_ _

V

Ó

©

quency index ranges over values, only values of ÑÒ© and need to be

:

_ _ _

V

Ó

©

computed since ÑÔ© and are periodic in with period .

_ _ _

For example, for &9™ :

92 Õ

even input data ¢¤©  ¦¢¤©  d¢¤©ÖŒ$ ¦¢ © ×

‰

Õ d¢¤©4H ¦¢¤© Í

odd input data ¢ ©¦ d¢¤©

F

E

Å

Ó

©  ›&tÑÒ©  p ©C 

F

<

Å

Ó

©¦‘ ›&tÑÒ©¦ p ©

V

F

Å

Ó

©4H ›&tÑÒ©4 p © 

‰ ‰ F ‰

Å

Ó

© ›&tÑÒ© prq ©



F

E

Å Å

Ó Ó

©CŒ ›&tÑÒ©  pts ©C  ›&tÑÒ©C  p ©C 



F

<

Å Å

Ó Ó

©4H ›&tÑÒ©¦ p © ›&tÑÒ© p ©

Ã

V



F

Å Å

Ó Ó

© × ›&tÑÒ©4 p ©  ›&tÑÒ©  p © 

u



‰ F ‰ ‰ ‰

Å Å

Ó Ó

©4ÍH ›&tÑÒ© pvË © ›&tÑÒ© prq ©

This is shown graphically on the flow graph of Fig 7.8: G[0] f[0] F[0] f[2] N/2 point f[4] DFT f[6] G[3] H[0] f[1] f[3] N/2 f[5] point DFT f[7] F[7] H[3]

Figure 7.8: FFT flow graph 1.

Assuming than is a power of  , we can repeat the above process on the two

: : V

-point transforms, breaking them down to -point transforms, etc  , until we

s & ™

come down to  -point transforms. For , only one further stage is needed

&ZHÙ (i.e. there are Ø stages, where ), as shown below in Fig 7.9.

Thus the FFT is computed by dividing up, or decimating, the sample sequence  ¢¤©  into sub-sequences until only -point DFT’s remain. Since it is the input, or time, samples which are divided up, this algorithm is known as the decimation- in-time (DIT) algorithm. (An equivalent algorithm exists for which the output, or frequency, points are sub-divided – the decimation-in-frequency algorithm.) The basic computation at the heart of the FFT is known as the butterfly because of its criss-cross appearance. For the DIT FFT algorithm, the butterfly computa- tion is of the form of Fig 7.10

93 f[0] N/4 point F[0] f[4] DFT

f[2] N/4 point f[6] DFT f[1] N/4 point f[5] DFT f[3] N/4 point DFT f[7] F[7]

Figure 7.9: FFT flow graph 2.

Ú Ú

Û

F

p*Ü

:

àRá

Ý

Þ à

Þ à

Þ à

Þ à

Þ à

Þ à

Þ à

Þ à

Þ à

à Þ

à Þ

F

à Þ

à Þ

Ü

p

:

à Þ

à Þ



à Þ

à Þ

Ü

p

:

à Þ

Ú

Û  Û

ÞRß

Ý

p*Ü :

Figure 7.10: Butterfly operation in FFT. Ú where and Û are complex numbers. Thus a butterfly computation requires one complex multiplication and 2 complex additions.

Note also, that the input samples are “bit-reversed” (see table below) because at each stage of decimation the sequence input samples is separated into even- and

odd- indexed samples.

(NB: the bit-reversal algorithm only applies if is an integral power of  ).

94 Index £[§ Binary Bit-reversed Bit-reversed representation Binary index 0 000 000 0 1 001 100 4 2 010 010 2 3 011 110 6 4 100 001 1 5 101 101 5 6 110 011 3 7 111 111 7

7.3.2 Computational speed of FFT V

The DFT requires complex multiplications. At each stage of the FFT (i.e. :

each halving) V complex multiplications are required to combine the results of

V § the previous stage. Since there are £BâBUã stages, the number of complex mul-

tiplications required to evaluate an -point DFT with the FFT is approximately

e

E

V

b

:

|‹âBUã p p

(approximately because multiplications by factors such as , : ,

e ä ä e

p pµå :

: and are really just complex additions and subtractions).

V

:

V V (DFT) â,Uã (FFT) saving

32 1,024 80 92 æ

256 65,536 1,024 98 æ

1,024 1,048,576 5,120 99.5 æ

7.3.3 Practical considerations

If is not a power of  , there are 2 strategies available to complete an -point

FFT.

1. take advantage of such factors as possesses. For example, if is divisi-

‰ ‰

ble by (e.g. &ČR™ ), the final decimation stage would include a -point transform.

95

2. pack the data with zeroes; e.g. include 16 zeroes with the 48 data points

×$Œ (for &vŒR™ ) and compute a -point FFT. (However, you should again be wary of abrupt transitions between the trailing (or leading) edge of the data and the following (or preceding) zeroes; a better approach might be to pack the data with more realistic “dummy values”).

96