You are on page 1of 15

Lecture 7 - The Discrete Fourier Transform

7.1 The DFT


The Discrete Fourier Transform (DFT) is the equivalent of the continuous Fourier Transform for signals known only at instants separated by sample times (i.e. a nite sequence 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

We could in principle evaluate this for any , but with only data points to start with, only nal outputs will be signicant. You may remember that the continuous Fourier transform could be evaluated over a nite interval (usually the fundamental period ) rather than from to 82

# YcbaC YXV HeC r 01 $# # pstHIC h'& p # #$# psrIC h  qC hg ` G E c G E c HG E p i G E d QP HG E feC YcaC YXW@ b` V

i w yxt

8 53 u764

ie.

 SR&

We could regard each sample as an impulse having area integrand exists only at the sample points:

. Then, since the

c t HG E IC h'&

A C 8 53 9764 Q H E DP"IGC FD 2 A B@  # #   # # #    )$$# ('&%$$$"!  0 1  ` aC v X  '& 2

8 53 U76T

if the waveform was periodic. Similarly, since there are only a nite number of input data points, the DFT treats the data as if it were periodic (i.e. to 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

10

11

(b) 1 0.8 0.6 0.4 0.2 0

10

15

20

25

30

Since the operation treats the data as if it were periodic, we evaluate the DFT equation for the fundamental frequency (one cycle per sequence, Hz, rad/sec.) and its harmonics (not forgetting the d.c. component (or average) at ).

or, in general

83

r

# # $# $

h  i8

## # $$!

f G E t gde 6C h'&

` aC v X

iywt 8 %

  8 5

i.e. set

c X `

0 1

"!

"!

 8

Figure 7.1: (a) Sequence of

samples. (b) implicit periodicity in DFT.

r

"!

 

r!

r

0 1

85 c X

! 

s s 8 q

8 & 8 t 'r  8 r
to

8 )y p  ! ) r(6 ! p "  " u d 0


Let the continuous signal be

n nn nn m

u p s tp p 

q vp p  p

"!    g

o q C kl nn C kk nn aC ` jkk nnn m

X

p$$ ## X p$$# ## X p#$$## # ## $$#  '&

wrp urp qrp 

n nn nn m

 8  kkl  kk  kk jk

"!   2  g 2 2

We may write this equation in matrix form as:

is the Discrete Fourier Transform of the sequence

. . .

. . .

. . .



0 1

 ~8 p }"'3 {8 p | ! z yx X 8 p 0 #$#$# q p C X p ` aC X p   C X 0 2 o


and etc. .

at 4 times per second (ie. Let us sample values of the discrete samples are given by:

DFT example

where

10

Figure 7.2: Example signal for DFT.

dc

84 1Hz
5 6

by putting
7

& { 6 p  & S6! p t%'&  8  d 0

= 4Hz) from 2Hz


8

10

. The

kl kk jkk 

f G E t gde C d'&

 

0 0

    kl jk

nn m

3  3 0 !  o r o  0 8 o "! 3  3  6! 0 kl  g kl n  jk nn m jk n m

3  3 0 0

i w yxt i  8 t f '3 0 e'& q v 8 t f "C d'& q v % 2 G E 8

 8 8  8 8  % t"! %  t
, , ,

The inverse transform of

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

Inverse Discrete Fourier Transform

|F[n]|

i.e.

Therefore

10

15

20

Figure 7.3: DFT of four point sequence.

85

` aC v X

iywt 8 % 2

f (Hz)

2 2 2 2 jkkl

  8 o "!  nn m g

is

Note that the coefcients are complex. We can assume that the values are real (this is the simplest case; there are situations (e.g. radar) in which two inputs, at each , are treated as a complex pair, since they are the outputs from o and o demodulators). and (reIn the process of taking the inverse transform the terms member that the spectrum is symmetrical about ) combine to produce frequency components, only one of which is considered to be valid (the one at the Hz where ; the higher frequency lower of the two frequencies, component is at an aliasing frequency ( )).

(7.2)

But

8 %

i.e.

(i.e. the complex conjugate)

86

&

1 for all

f E t gde 6G 8 t d6G E e

i w yt

t C E G

8 %

8 b f C de C E t XV G

 '&

For all

real

t b f C XV de C h'& G E

E t "4b f C YXV de G h

 '&

From the inverse transform formula, the contribution to is:

of

and

0 2

 'R&

0 2

p f h %'& f E 8  0 1 2 t gde G 2 

` aC v X

0 2

c B

i.e. the inverse matrix is ric) matrix.

i yw f 8  f E t de G h 2 v  %'R& ` aC X `
times the complex conjugate of the original (symmet-

0 2

&

& {  8 t G drR! E 8 h"! %'& E 8  2  t de G 2 


component

X 8

! & ut  ! 8 '& $ ! "! 0


o

s ! 8 r 8   8 3 { 8 2 0

2 2

s  r8 i %g ` X 8  2

8" X '& i 'R&  8    2 8  'R&` " 8  2


, is

#  X 2

c f X

& 8  f d 2 6p ' "!  2 ! %'& &

T  &  "%' '& f 8  "! "! ! 2 0 2


since

 8 t G E

Substituting into the Equation for

8  f f G rt gde C EF 2 t gde G d 2  %'R& p f E  '& f

For the special case of contribution of to nent.

i.e. a sampled sinewave at

ie.

or

Hz, of magnitude

above gives,

(i.e. sum of all samples) and the average of d.c. compo-

8  '&

Interpretation of example

 g

1.

! 8  6rg

2.

implies a d.c. value of

implies a fundamental component of peak amplitude o with phase given by

8  

2 

i.e.

(as expected)

X 2

3.

! 8  r%"!

since

for all

no other

87

&
(as expected) (as expected)

 8 & ti{h

component here) and this implies a

6 5 4 |F[n]| 3 2 1 0 0 1 f (Hz) 2 3 sqrt(2) 3/sqrt(2)

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): In typical applications, is much greater than ; for example, for , has components, but are the complex conjugates of , as the d.c. component, to as complete a.c. comleaving ponents and frequency as the cosine-only component at the highest distinguishable .

Most computer programmes evaluate (or for the power spectral density) which gives the correct shape for the spectrum, except for the values at and .

7.2 Discrete Fourier Transform Errors


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

88

 6  ! 0 8

qs i ) f` ` e`

X f )

{s f` ) i ` !    0  X ) f

X ) `

8 s if` ` s i f )` ! ( i  X

 8

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

7.2.2 Leakage
Recall that the continuous Fourier transform of a periodic waveform requires the or over an integer number integration to be performed over the interval - to 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 number of cycles in the data samples. The DFT for this case (for to ) is shown below in 7.5.
8

6 |F[n]|

4 freq

Figure 7.5: Leakage. We might have expected the DFT to give an output at just the quantised frequen89

X 8

 8

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

0.5

0.5

10

15

20

25

30

35

40

45

50

Figure 7.6: Leakage. The repeating waveform has discontinuities. Most sequences of real data are much more complicated than the sinusoidal sequences that we have so far considered and so it will not be possible to avoid introducing discontinuities when using a nite 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 lters (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) 7 6 5 4 3 2 1 0 0 2 4 6 8 1 0 3 2 5 4 (b)

Figure 7.7: Leakage is reduced using a Hanning window.

90

7.3 The Fast Fourier Transform


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 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 consideration. Highly efcient computer algorithms for estimating Discrete Fourier Transforms have been developed since the mid-60s. These are known as Fast Fourier Transform (FFT) algorithms and they rely on the fact that the standard DFT involves a lot of redundant calculations:

it is easy to realise that the same values of are calculated many times as the computation proceeds. Firstly, the integer product repeats for different combinations of and ; secondly, is a periodic function with only distinct values.

Then

From the above, it can be seen that:

91

 ~8

WS7S 8 3 8 3 8 u 8 0  8 s iS3 8 8 q 3 8 0 0 0 0 ! # a8 8 s C t8 d C t8 ` p G E G E 3  0

W8

For example, consider of 2)

(the FFT is simplest by far if

is an integral power

say

iywxt 8 %

&

t fX p

t fX p

iywt 8 

Re-writing

as

p t f X d'&

` aC v X

G E t f de C h'&

` aC v X

&

7.3.1 Decimation-in-time algorithm


Let us begin by splitting the single summation over samples into 2 summations, each with samples, one for even and the other for odd. Substitute for even and for odd and write:

Note that

Therefore

Thus the -point DFT can be obtained from two -point transforms, one on even input data, , and one on odd input data, . Although the frequency index ranges over values, only values of and need to be computed since and are periodic in with period . For example, for :

i yw i yw p p 8 X p f e d  p ! p f e dR! v % 2 v ` aC e ` aC e

ie.

92

p f b` V X d  p !

p E f e r8 f d e C W8 b f V de C t8 f X p G E G

X  

 X   iX p p  t% 8 2

&

&

i yw i yw 8 % p X dR! 2 v p f v ` aC e ` aC e

` C 8 a t &

 8 ri&

 t8

eg. if

and

q t8 q s 8 q t8 q p

W8 

&

8 t X

&

Also, if

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

q vp p 0 0 ` p 0 i p 0

8 vp 8 u p 8 p 8 tp s

odd input data

This is shown graphically on the ow graph of Fig 7.8:


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

Figure 7.8: FFT ow graph 1. Assuming than is a power of , we can repeat the above process on the two -point transforms, breaking them down to -point transforms, etc , until we come down to -point transforms. For , only one further stage is needed (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 DFTs remain. Since it is the input, or time, samples which are divided up, this algorithm is known as the decimationin-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 buttery because of its criss-cross appearance. For the DIT FFT algorithm, the buttery computation is of the form of Fig 7.10 93

## $$#

18 s X

 "!    g

q rp p 0 ` p 0 i p 0

   "rRd d      6d"!" ! r8 ! ! 0  t 8  8  "! t"!  t8  gt8g  "!    g


F[7]

8  vp p  trR  8  u p "R!t"  8  p p  trR  8  tp p tg s q 8 rp p  t  8  p pp "R! trR!  8   ` p  t  8  i p pp t" !  '& X 2 2 2 2 2 2 2

even input data

f[0] f[4] f[2] f[6] f[1] f[5] f[3] f[7]

N/4 point DFT N/4 point DFT N/4 point DFT N/4 point DFT

F[0]

F[7]

Figure 7.9: FFT ow graph 2.

where and are complex numbers. Thus a buttery 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.

94

(NB: the bit-reversal algorithm only applies if

X Bp 0 X p 0 X p p X Bp p
Figure 7.10: Buttery operation in FFT. is an integral power of ).

0 1 2 3 4 5 6 7

7.3.2 Computational speed of FFT


complex multiplications. At each stage of the FFT (i.e. The DFT requires each halving) complex multiplications are required to combine the results of the previous stage. Since there are stages, the number of complex multiplications required to evaluate an -point DFT with the FFT is approximately (approximately because multiplications by factors such as and are really just complex additions and subtractions).

7.3.3 Practical considerations


If is not a power of , there are 2 strategies available to complete an FFT.

1. take advantage of such factors as possesses. For example, if is divisi), the nal decimation stage would include a -point ble by (e.g. transform.

95

32 256 1,024

(DFT) 1,024 65,536 1,048,576

(FFT) saving 80 92 1,024 98 5,120 99.5

X p iX p e

ff

D X

& ( e

Index

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

X X p p ! e f|

-point

2. pack the data with zeroes; e.g. include 16 zeroes with the 48 data points (for ) 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).

v8

96

You might also like