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:
(98;: =+ <>;?
6!$#%7& 
 
 
 
 - +/A02B3 
@
 8;:
&  C  D- +/EGF   D- +/10H?IF  F   D- +/10J?IF  H- +/A0 +=<>;?
: L +=<
ie. "!$#%K&   D- +/10J?
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
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
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 operation treats the data as if it were periodic, we evaluate the
<
VXW equation for the fundamental frequency (one cycle per sequence, : ? Hz,
DFT
: ? rad/sec.) and its harmonics (not forgetting the d.c. component (or average) at
#Y&Z ).
H\ \ \ \ 
i.e. set #Y&Z [  ^   U
 S] ]`_ S]
or, in general

: L +=<
S
 &   D- + /$bdg
ec f J  Z& ih H
_ JaMOE _

83
is the Discrete Fourier Transform of the sequence   .
_
We may write this equation in matrix form as:
jkk mnn jkk m nn jkk mnn
kk C  nn kk    V   : +=< nn kk  C  nn
kl  n kk  p V p p q
r Tp : + V nn kl   n
 p pts p u
r Tp
 & lk  pvq p u p w
r Tp : + q n  
.. o .. o
.. o
S.
. V  .
  p : +=< p : + p : + q  p  
 V
where p &Zxy[z{ !\}|  and p &Zp : etc. ~ & .

DFT – example
Let the continuous signal be

ˆ‡ @ Š
K& € ‚ƒ F €  „…$†UH\‚  ƒ  F € ‰ „…‹†O‚ Œ\ƒ 
dc 1Hz 2Hz

10

−2

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

Figure 7.2: Example signal for DFT.

Let us sample  at 4 times per second (ie.  = 4Hz) from Ž&r to Ž& q . The
values of the discrete samples are given by: s
W “‡ @ F”‰
  &t F $‘’5 V   •$’\{ by putting &r–—&
J
s

84
i.e. 
 ˜&t™ ,   &šŒ ,   ›&t™ ,  ‰ &Z ,  &ZŒR

L q L q 
Therefore  &   d- + /c b f J &   A ! f J
_ E JNMOE
jkkl mn kjlk mnn kjlk m n kjlk m n
C  n      C  n  $ n
 &   !  ! o   & R! Œ
‰ o      

‰ 
 o H
  o
 !  !  !RŒ
The magnitude of the DFT coefficients is shown below in Fig. 7.3.

20

15
|F[n]|

10

0
0 1 2 3
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

4 & D -Uœ / bdec f J
f MOE _
<
i.e. the inverse matrix is : times the complex conjugate of the original (symmet-
ric) matrix.

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  fre-
quency components, only one of which VXW is considered to: be valid (the one at the
V ; the higher frequency
_*] ?
lower of the two frequencies, Hz where
: V _ Ÿ
component is at an “aliasing frequency” ( )).
_Š¡
¢
From the inverse transform formula, the contribution to   of and
is:
_ _

  8;:
 f  & š£ D - / bdg
e c f J¤F D- / bde c + f >"J¥ (7.2)
_ _

: L +=<
S 8 :
For all   real  &   D- +/bde c + f >¦J
_ JaMOE

8: VXW
But - + /bde c + f ¦> J & € - +  / ‚ ƒ J - œ $/ bdec¨§ J &Z- œ $/ bdg
ec f J
1 for all 
S ª©
i.e. &   (i.e. the complex conjugate)
_ _

86
Substituting into the Equation for  f  above gives,
 J F ©  .- +/ bdegc f JH¥ VXW
 f 4 & £ d - / db egc f ¤ since - / J &T
_ _

  \ š­¦®  \ ¥
ie.  f  ›& £«¬£ ¥ ‘„ …‹†  £ ¥ ¨† ¯6° 
_ _ _ _
  \
or  f  & T± ± „‘…‹† £   F”²$³¨´  d ¥
_  _ _
VXW f V
i.e. a sampled sinewave at : ? Hz, of magnitude : ± _ ±
For the special case of &µ ,  Ž&S¶·
4 (i.e. sum of all samples) and the
contribution of C  to
_
4 is  E  ¤& : <  —& average of   ¤& d.c. compo-
nent.

Interpretation of example
< VE
1. C  ›&r$ implies a d.c. value of : C  & &r (as expected)
s
 ª© ‰
2. V  {& R! Œ¸
V & ²³¨´  ›& ¹‡ o
implies a fundamental component of peak amplitude
: ± ¦‘ ± & s ] Œª&r with phase given by

\ ˆ‡ \ Y‡


i.e. „…‹†  o¤
 &tK„‘…‹†U  o (as expected)
 

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

 V  &
 e c »V J & 
 D- / bd¼
W
4H d- / J & ‰ ‘’\{ (as expected)
Œ
since †¨¯D°\{i&t for all 

87
6

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

2 sqrt(2)

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

has U ‹Œ components, but ^ ‰ V U R ‰ are theV complex conjugates of ^$  ,
_ EÀ <À <A<À
leaving <B¾E ¿ V as the d.c. component, <BE V ¾Â ¿ V to <BE V ¾Â ¿ à V as complete a.c. com-
s < <VÀ s{Á Á sGÁ Á
ponents and <BE V s ¾Â ¿ à V as the cosine-only component at the highest distinguishable
:V
frequency  & .
_
Most computer programmes evaluate ¾: ¿ (or ¾: ¿
fÀ fÀb
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 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
P F P or over an integer number
Recall that the continuous Fourier transform of a periodic waveform requires the
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.
_ _

6
|F[n]|

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 Fourier series for the
waveform in Fig. 7.6, which has major discontinuities, hence other frequency
components.
1

0.5

−0.5

−1
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 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 Fast Fourier Transform
The time taken to evaluate a DFT on a digital computer depends principally on the
V are the slowest operations. With
number of multiplications involved, since these
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 algorithms 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 +=<
Re-writing › &   D- +/ bde c f J as  &   dp : f J
_ JaMOE _ JNMOE
J
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 com-
J _
binations of  and ; secondly, p : f is a periodic function with only distinct
values.
_

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


Å < 
+ / b dÆ c +  /  !
p &t- & - s ÃXÇ & È
t & É= say 
Z

V    © 
Then É & ! ÉRq& !5Éi& É És & 
 © Å
ÉÃ & É É u &Ê! É5Ë%&Ê!5ÉÌ&9É É ~& 
From the above, it can be seen that:

91

ptÅ s &  p ÅE
p ÅÃ &  p Å V<
p Åu &  p Å
pvÅ Ë & pvÅ q
Also, if  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
Substitute ÏS& V for  even and ÏS&
J‘+=V < for  odd and write:

e =+ < e =+ <
Lb VÐ Lb 8 V Ð < >
& 
4ϸ dp : f F  Ï F  dp : œ f
_ Ð OM E Ð MOE

VÐ f 
+ / d
b c 8V Ð f > + / bde c Ð f Ð
Note that p : t & - e & - b
9 &rp e f
b

e =+ < e =+ <
Lb Ð Ð Lb Ð
Therefore & 
4ϸ dp e f F p :  Ï F  dp e f
_ Ð OM E b Ð MOE b

Ð
ie.  &tÑÒ F p :iÓ
_ _ _
:
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
‰ d 4H  Í
 ›&tÑÒ  F p ÅE Ó C 
¦‘ ›&tÑÒ ¦ F p Å< Ó 
4‰H ›&tÑÒ 4‰ F p ÅV Ó ‰
›&tÑÒ F prÅ q Ó
F ptÅ s Ó  ÅE
CŒ ›&tÑÒ  F p Å Ó C  ›&tÑÒ C   p Å< Ó C 
4H ›&tÑÒ ¦ F p Å Ãu Ó  ›&tÑÒ   p ÅV Ó 
× ›&tÑÒ 4‰ F pvÅ Ë Ó ‰ ›&tÑÒ ‰  p Å Ó ‰
4ÍH ›&tÑÒ ›&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
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 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] F[0]
N/4 point
f[4] DFT

f[2]
N/4 point
f[6] DFT

f[1]
N/4 point
f[5] DFT

f[3]
N/4 point
f[7] DFT
F[7]

Figure 7.9: FFT flow graph 2.

Ú Ú F Û
Þ Þ à R
à á Ý p*: Ü
Þ Þ à à à
Þ Þ à
Þ Þ à à à
Þà àÞ
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.
:V
each halving) complex multiplications are required to combine the results of
the previous stage. Since there are BâBUã V  stages, the number of complex mul-
tiplications required to evaluate an -point DFT with the FFT is approximately e
|‹e ä âBUã V (approximately E
because multiplications by factors such as p : , p : b
äe ,
p : and pµ: å are really just complex additions and subtractions).

V :V
(DFT) â,Uã V (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

You might also like