The DFT

Whereas the CTFT takes a continuous signal and outputs a continuous frequency spectrum and the DTFT takes a discrete signal and outputs a continuous, periodic frequecy spectrum, the Discrete Fourier Transform takes a discrete finite signal and outputs a discrete frequency spectrum. This is useful for signal processing because we cannot store infinite signals in a computer’s memory.

Definition 1

For a length NN finite sequence {x[n]}0n1\{x[n]\}^{n-1}_{0}, the Discrete Fourier Transform of the signal is a length N finite sequence {X[k]}0n1\{X[k]\}^{n-1}_{0} where

X[k]=n=0N1x[n]ej2πNknX[k] = \sum_{n=0}^{N-1}{x[n]e^{-j\frac{2\pi}{N}kn}}

One way to interpret the DFT is in terms of the Fourier series for a disrete periodic signal x~[n]=x[((n))N]\tilde{x}[n]=x[((n))_N] where the ((n))N=nmodN((n))_N = n \mod N. Recall that the coefficient of the kth term of the Fourier Series is

ak=1Nn=0N1x[n]ej2πNkna_k = \frac{1}{N}\sum_{n=0}^{N-1}{x[n]e^{-j\frac{2\pi}{N}kn}}

Notice that the aka_k of the Fourier Series are the DFT values except scaled by a factor of NN. In other words, if we extend a finite signal periodically, then the DFT and the DTFS are the same up to a constant scale factor. This gives an intuitive inverse DFT.

Definition 2

For a length N finite sequence {X[k]}0N1\{X[k]\}^{N-1}_{0} representing the DFT of a finite perioidc signal {x[n]}0N1\{x[n]\}^{N-1}_{0}, the inverse DFT is given by

x[n]=1Nk=0N1X[k]ej2πNknx[n] = \frac{1}{N}\sum_{k=0}^{N-1}{X[k]e^{j\frac{2\pi}{N}kn}}

Notice that the DFT and the IDFT are very similar in form. It turns out that the IDFT can be expressed as a DFT of X[k]X^*[k]. Namely

IDFT{X[k]}=1NDFT{X[k]}IDFT\{X[k]\} = \frac{1}{N}DFT\{X^\star[k]\}^\star

Further intuition for the DFT comes by relating it to the DTFT. Suppose we have a finite signal x[n]x[n] which is 00 for n<0n < 0 and n>N1n > N-1. The DTFT of this signal is

X(ω)=n=x[n]ejωn=n=0N1x[n]ejωnX(\omega) = \sum_{n=-\infty}^{\infty}{x[n]e^{-j\omega n}} = \sum_{n=0}^{N-1}{x[n]e^{-j\omega n}}

Suppose we sample the DTFT at intervals of 2πNk\frac{2\pi}{N}k, then the kth sample is given by

X[k]=X(2πNk)=n=0N1x[n]ej2πNknX[k] = X\left(\frac{2\pi}{N}k\right) = \sum_{n=0}^{N-1}{x[n]e^{-j\frac{2\pi}{N}k n}}

Thus we can think of the DFT as a NN evenly spaced samples of the DTFT. One important point to notice is that while the DTFT is often centered around 0 (meaning it is plotted over a range from π-\pi to π\pi), because we are summing from 0 to N-1 in the DFT, the DFT coefficients are centered around π\pi, and thus they are plotted on a range fo [0,2π2πN][0, 2\pi - \frac{2\pi}{N}]

Convolution and the DFT

Circular Convolution

When the DFT coefficients of two signals are multiplied, the resulting coefficients describe a circular convolution of the original two signals.

x[n]y[n]X[k]Y[k]x[n]\circledast y[n] \leftrightarrow X[k]Y[k]

Definition 3

A circular convolution between two finite sequences is given by

x[n]y[n]=m=0N1x[m]y[((nm))N]x[n]\circledast y[n] = \sum_{m=0}^{N-1}x[m]y[((n-m))_N]

The mechanics of the circular convolution are the same as that of the regular convolution, except the signal is circularly shifted as shown in Figure 1.

A circular convolution is equivalent to a periodic convolution over a single period.

Linear Convolution with the DFT

Because multiplying DFT coefficients performs a specific case of convolution, we can compute a linear convolution using the circular convolution. Suppose we have two finite signals {x[n]}0L1\{x[n]\}_0^{L-1} and {h[n]}0P1\{h[n]\}_0^{P-1} The linear convolution of these two signals will be length L+P1L+P-1, so in order to take an IDFT and get L+P1L+P-1 samples, we need to take at least NL+P1N\le L+P-1 points.

  1. Pad each vector to length L+P1L+P-1

  2. Compute X[k]H[k]X[k]H[k]

  3. Take the Inverse DFT

If NN is smaller than LP+1L-P+1, the result is akin to aliasing in the time domain. To see why, consider that the DFT coefficients are essentially the DTFS coefficients of the periodic extension of x[n]x[n] (denote x~[n]\tilde{x}[n]).

x~[n]=r=x[nrN]\tilde{x}[n]=\sum_{r=-\infty}^{\infty}x[n-rN]

If we compute the DTFT of each periodic extension, then

Y(ejω)=X(ejω)H(ejω)Y(e^{j\omega})=X(e^{j\omega})H(e^{j\omega})

and the IDTFT of this will be

y~[n]=r=y[nrN].\tilde{y}[n] = \sum_{r=-\infty}^{\infty}y[n-rN].

Notice that if NN is not large enough, then these copies will be overlapping (a.k.a aliasing). Since the DFT is just sampling the DTFT, the circular convolution will represent the true convolution so long as the copies don’t overlap.

Block Convolutions

In a discrete time system, the input signal might have a very long length, making it impractical to be stored in a computer’s memory or to compute the DFT of it all at once (especially if we have a real-time system). Thus to compute the output of a digital filter (with impulse response of length PP), we need to compute the DFT in blocks shorter than the signal.

The first method of block convolution is the overlap-add method.

  1. Decompose x[n]x[n] into nonoverlapping segments of length LL

    x[n]=rxr[n]xr[n]={x[n]rLn(r+1)L0else.x[n] = \sum_{r}x_r[n] \qquad x_r[n] = \begin{cases} x[n] & rL \le n \le (r+1)L\\ 0 & \text{else}. \end{cases}

  2. Since convolution is linear,

    y[n]=x[n]h[n]=rxr[n]h[n].y[n] = x[n]*h[n]=\sum_r{x_r[n]*h[n]}.

  3. Zero pad xr[n]x_r[n] and h[n]h[n] to length NL+P1N\ge L+P-1 to prevent time-domain aliasing

  4. Compute the DFTs, multiply them, and take the inverse DFT.

  5. The neighboring outputs overlap in the last P1P-1 points, so add the overlapping sections together to get the final output

The other method of block convolution is the overlap-save method.

  1. Divide x[n]x[n] into sections of length LL such that each section overlaps the previous by P1P-1 points

    xr[n]=x[n+r(LP+1)P+1]0nL1x_r[n]=x[n+r(L-P+1)-P+1] \qquad 0 \le n \le L-1

  2. Zero pad xr[n]x_r[n] and h[n]h[n] to length NL+P1N\ge L+P-1 to prevent time domain aliasing.

  3. Compute the DFTs, multiply the coefficients, and compute the inverse DFT.

  4. The first P1P-1 samples of the output will be incorrect, so we can discard them.

    y[n]=r=0yr[nr(LP+1)+P1]yr[n]={xr[n]h[n]P1nL10 elsey[n]=\sum_{r=0}^{\infty}y_r[n-r(L-P+1)+P-1] \qquad y_r[n]= \begin{cases} x_r[n]*h[n] & P-1\le n \le L-1\\ 0 & \text{ else} \end{cases}

FFT

The DFT gives us an easy way to do convolutions. Unfortunately naiively, computing it is an O(N2)O(N^2) operation because we must sum together NN elements to compute NN different coefficients. Thankfully, there is a fast algorithm which can compute the DFT in O(NlogN)O(N\log N) time so we can compute convolutions quickly.

Definition 4

The fast fourier transform is an algorithm which computes the DFT efficiently in O(NlogN)O(N\log N)time.

It works by exploiting properties of the Nth roots of unity.

Definition 5

The Nth roots of unity are the complex roots of WNN=1W_N^N=1.

WNk=ej2πkNW_N^k=e^{-j\frac{2\pi k}{N}}

The roots of unity have the following properties.

Theorem 1

The Nth roots of unity are conjugate symmetric.

WNNkn=WNkn=(WNkn)W_N^{N-kn} = W_N^{-kn} = (W_N^{kn})^\star

Theorem 2

The Nth roots of unity are periodic in N.

Wkn=WNk(n+N)=WN(k+N)nW_{kn} = W_N^{k(n+N)} = W_N^{(k+N)n}

Theorem 3

When squared, the Nth roots of unity become the N2\frac{N}{2}th roots of unity.

WN2=WN2W_N^2 = W_\frac{N}{2}

Using Theorem 1, Theorem 2, Theorem 3, we can take two approaches to the FFT: decimation in time, which splits x[n]x[n] into smaller subsequences, and decimation in frequency which splits X[n]X[n] into smaller subsequences.

Decimation in Time

The idea here is too break x[n]x[n] into smaller subsequences. We assume that NN is a power of 2 for simplicity.

X[k]=n=0N1x[n]WNkn=n evenx[n]WNkn+n oddx[n]WNknX[k]=\sum_{n=0}^{N-1}x[n]W_N^{kn} = \sum_{\text{n even}}x[n]W_N^{kn}+\sum_{\text{n odd}}x[n]W_N^{kn}

We let n=2rn=2r and n=2r+1n=2r+1.

X[k]=r=0N21x[2r]WN2rk+r=0N21x[2r+1]WNk(2r+1)=r=0N21x[2r]WN2rk+WNkr=0N21x[2r+1]WN2kr\begin{aligned} X[k] &= \sum_{r=0}^{\frac{N}{2}-1}x[2r]W_N^{2rk}+\sum_{r=0}^{\frac{N}{2}-1}x[2r+1]W_N^{k(2r+1)}\\ &= \sum_{r=0}^{\frac{N}{2}-1}x[2r]W_{\frac{N}{2}}^{rk}+W_N^k\sum_{r=0}^{\frac{N}{2}-1}x[2r+1]W_{\frac{N}{2}}^{kr}\\\end{aligned}

These are just the DFTs of the even and odd elements of the signal!

X[k]=G[k]+WNkH[k]\begin{aligned} \therefore X[k] = G[k] + W_N^kH[k]\end{aligned}

Both GG and HH are N2\frac{N}{2} periodic, and notice that

WNk+N2=ej2πN(k+N2)=WNk.W_N^{k+\frac{N}{2}}=e^{-j\frac{2\pi}{N}(k+\frac{N}{2})}= -W_N^k.

This means once we compute G[k]G[k] and H[k]H[k] we can compute X[k]X[k] easily because

X[k]=G[k]+WNkH[k]X[k+N2]=G[k]WNkH[k]for k[0,N2)X[k] = G[k]+W_N^kH[k]\qquad X\left[k+\frac{N}{2}\right]=G[k]-W_N^kH[k] \qquad \text{for }k\in\left[0, \frac{N}{2}\right)

We can continue this relationship recursively downwards. Once we get too N=2N=2, we can represet this as a simple butterfly operation:

X[0]=x[0]+x[1]X[1]=x[0]x[1].X[0] = x[0]+x[1] \qquad X[1] = x[0]-x[1].

Decimation in Frequency

The decimation in frequency approach is very similar to the decimation in time approach except instead we split the frequency components

X[2r]=n=0N21x[n]WN2rn+n=0N21x[n+N2]WN2r(n+N2)=WN2rnn=0N21(x[n]+x[n+N2])X[2r+1]=WN2rnn=0N21(x[n]x[n+N2])\begin{aligned} X[2r] &= \sum_{n=0}^{\frac{N}{2}-1}x[n]W_N^{2rn}+\sum_{n=0}^{\frac{N}{2}-1}x\left[n+\frac{N}{2}\right]W_N^{2r\left(n+\frac{N}{2}\right)}=W_{\frac{N}{2}}^{rn}\sum_{n=0}^{\frac{N}{2}-1}\left(x[n]+x\left[n+\frac{N}{2}\right]\right)\\ X[2r+1] &= W_{\frac{N}{2}}^{rn}\sum_{n=0}^{\frac{N}{2}-1}\left(x[n]-x\left[n+\frac{N}{2}\right]\right)\end{aligned}

Last updated