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 finite 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

"!$#%'&

(*)

+/102,3 


,



.

+ )

We could regard each sample   as an impulse having area  45 . Then, since the
integrand exists only at the sample points:

6!$#%7&
&

(98;: =+ <>;?
+/A02B3 








@

8;:
 C  D- +/EGF   D- +/10H?IF  F   D- +/10J?IF 
H- +/A0 +=<>;?
ie.

"!$#%K&

: L +=<
JNMOE

  D- +/10J?

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

F P

if the waveform 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 is the same as  R to 
H .)
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

&TU

Figure 7.1: (a) Sequence of

20

25

30

samples. (b) implicit periodicity in DFT.

Since the operation treats the data as if it were periodic, we evaluate the
<
DFT
VXW equation for the fundamental frequency (one cycle per sequence, : ? Hz,
: ? rad/sec.) and its harmonics (not forgetting the d.c. component (or average) at
#Y&Z ).
i.e. set #Y&Z [

H\


\

S]

^

\

]`_



\

S]

or, in general

: L +=<

ec f J
 &
  D- + /$bdg
_
JaMOE
83

 Z
& ih
_

S

H



U

is the Discrete Fourier Transform of the sequence   .

We may write this equation in matrix form as:

jkk

C 



kk
kl

..
.

S

where p

mnn

jkk


& lk 

nn

kk 

kk 

p V

pvq

p u

p
..
.

 V


p q
r
p u
r
p w
r

pts


Tp
Tp
Tp

V

 p : +=< p : + p : + q 
V

&Zxy[z{ !\}|  and p &Zp : etc. ~
& .

m nn
+=< nn
: + V nn
: + q n
o
p

:

jkk

mnn

 C 
 
 
kk
kl


..
.



nn
n



DFT example
Let the continuous signal be

 @
K&   F  $UH\ 
 F O \ 
dc

2Hz

1Hz

10
8
6
4
2
0
2
4

10

Figure 7.2: Example signal for DFT.


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

W  @ F
  &t F $5 V 

$\{
84



= 4Hz) from &r to &


by putting &r&

J
s

. The

i.e.


 &t ,   & ,   &t ,  &Z

Therefore

jkkl

mn
kjlk
C  n

 &

 o




 &
_


 !

!

&ZR

L q

L q

  d- + /c b f J &
  A ! f J
E
JNMOE



mnn kjlk
m n
kjlk
m n
 C  n
 $ n
  &
R!
! o
o








H

 o


!

!R





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


20

|F[n]|

15

10

f (Hz)

Figure 7.3: DFT of four point sequence.

Inverse Discrete Fourier Transform


The inverse transform of

: L +=<

 &
  d- +/bdegc f J
_
JaMOE
85

is

: =+ <
 L
f MOE


4 &
:

i.e. the inverse matrix is


ric) matrix.

<

D -U / bdec f J
_

times the complex conjugate of the original (symmet-

Note that the coefficients are complex. We can assume that the 
4 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).

In the process of taking the inverse transform the terms and


(re:V
_
_
member that the spectrum is symmetrical about ) combine to produce  frequency components, only one of which
VXW is considered to: be valid (the one at the
V ; the higher frequency
Hz where
lower of the two frequencies,
: V _
_*] ?
component is at an aliasing frequency (
)).

From the inverse transform formula, the contribution to   of


is:


 f  &

e c f JF
D - / bdg
_

For all   real 

8:
- + /bde c + f > J &

But

i.e.

S
_

&

 
_

S



&

VXW
- +  / J

1 for all 

: L +=<
JaMOE

and

8;:
D- / bde c + f >"J
8 :
  D- +/bde c + f >J

ec f J
- $/ bdec J &Z- $/ bdg

(i.e. the complex conjugate)

86


_

(7.2)

Substituting into the Equation for 

 f 4 &

f  above gives,
J F  .- +/ bdegc f JH
d - / db egc f
_
_

 f  &

ie.


 \



_
_



i.e. a sampled sinewave at


For the special case of
contribution of C  to
nent.

VXW f
: ?

Hz, of magnitude

2.

3.

implies a d.c. value of




V  {& R!
V &
:  & s ] &r
i.e.

 \
6

_
_



 &H
component

 V  &

\


<

C  &

VE
&r
s

(as expected)

implies a fundamental component of peak amplitude


  &  o
with phase given by



:
 & V
_


V
: _ 

& ,  &S
4 (i.e. sum of all samples) and the
_
4 is  E  & : <  & average of   & d.c. compo-

Interpretation of example

C  &r$

VXW
- / J &T


 \
 f  & T 
 F$  d
_
_
 _

or

1.

since

\ Y
o
 &tKU 



no other

e c V J & 
 D- / bd

S
_

o

component here) and this implies a

W
4H d- / J & \{

since D\{i&t for all 


87

(as expected)

(as expected)

6
5

|F[n]|

4
3/sqrt(2)

3
sqrt(2)

2
1
0

1
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):
In typical applications,
is much greater than ; for example, for
&U R  ,

has U  components, but ^ V U R are theV complex conjugates of ^$  ,
E
<
<A<
_
leaving <BE V as the d.c. component, <BE V  V to <BE V  V as complete a.c. com-

ponents and
frequency 

<
<BE V s
&

<V
 V
:V
.

s{

sG

as the cosine-only component at the highest distinguishable

fb

Most computer programmes evaluate : (or :


for the power spectral den

sity) which gives the correct shape for the spectrum, except for the values at
:
&Z and V .

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 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 values 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 highfrequency spectral content.

7.2.2 Leakage
Recall that the continuous Fourier transform of a periodic waveform requires the
P
F P 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 num:
ber of cycles in the data samples. The DFT for this case (for & to & V )
_
_
is shown below in 7.5.
8

|F[n]|

4
freq

Figure 7.5: Leakage.


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

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 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 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)

5
4

2
1

1
0

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
V 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 efficient 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:

Re-writing

: L +=<

&
_
JaMOE

  D- +/ bde c f J
J

as

: L +=<

 &
  dp : f J
_
JNMOE

it is easy to realise that the same values of p : f are calculated many times as the
computation proceeds. Firstly, the integer product  repeats for different comJ
_
binations of  and ; secondly, p : f is a periodic function with only distinct
_
values.
For example, consider
of 2)

&9

(the FFT is simplest by far if

is an integral power



!
<

+
/
+

/
b
d
c

p &t& - s X &
t
& = say 
Z

V 



Then &
!
Rq& !5i&
s & 


&
u &!
5%&!5&9
From the above, it can be seen that:

91

~
& 

pt s
p
p u
pv
Also, if


&  p E
&  p V<
&  p
& pv q

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

eg. if

&t

and i&r^

p q &t q &  s q &t q

7.3.1 Decimation-in-time algorithm


Let us begin by splitting the single summation over samples into 2 summations,
:
each with V samples, one for  even and the other for  odd.
J
J+=V < for  odd and write:
Substitute S& V for  even and S&

e =+ <
Lb
V
8 V < >

4 dp : f F
  F  dp : f
&
_
OM E
MOE
e =+ <
Lb

Note that

+ / bde c f
V f

8V f >

+
/
d
b
c
e
& - b
9
p : t
& &rp e f
b
e =+ <
Lb

Therefore

e =+ <

Lb

&

4 dp e f F p :
  F  dp e f
_
b
b
OM E
MOE

 &t F p :i
_
_
_

ie.

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

For example, for

&9

:
92

even input data     d $ 



odd input data 
 d

 &t 
 &t 
4H &t 4
&t
C &t 
4H &t 
 &t 4
4H &t

F p E
F p <
F p V
F pr q
F pt s
F p
F p u
F pv

d 4H  

C 



C  &t C 
 &t 
 &t 
&t


E
 p <
 p V
 p
prq

C 



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


G[0]

f[0]
f[2]
f[4]
f[6]

N/2
point
DFT

f[1]
f[3]
f[5]
f[7]

N/2
point
DFT

F[0]

G[3]
H[0]

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
come down to  -point transforms. For
&s , only one further stage is needed
(i.e. there are stages, where &ZH ), 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 butterfly because
of its criss-cross appearance. For the DIT FFT algorithm, the butterfly computation is of the form of Fig 7.10
93

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

F[0]

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

F[7]

Figure 7.9: FFT flow graph 2.

p*:
R



F p :





R 

p
:

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

94

is an integral power of  ).

Index

[

0
1
2
3
4
5
6
7

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

7.3.2 Computational speed of FFT

complex multiplications. At each stage of the FFT (i.e.


The DFT requires
:V
each halving) complex multiplications are required to combine the results of
the previous stage. Since there are BBU V  stages, the number of complex multiplications required to evaluate an -point DFT with the FFT is approximately
e

E
because multiplications by factors such as p : , p : b
|e BU V (approximately
e
p : and p: are really just complex additions and subtractions).
V

32
256
1,024

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

:V

,U V

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

7.3.3 Practical considerations


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

-point

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 &vR ) 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

You might also like