---
title: Problem set 6
heading: "Problem set 6: sampling, spectra and the FFT"
eyebrow: C9 · Problem set 6
type: problems
---

::: hook
These problems use lessons 21 to 29: sampling and reconstruction, changing the sample rate, the DFT, windows and leakage, the FFT and fast convolution, and the spectral analysis lab.
:::

::: pool
pick: 12

::: check
kind: parts
given: f = 3.3 | 7.1 | 12.6 | 19.2; fs = 8 | 10

## A {f} kHz tone is sampled at {fs} kHz.

::: part
answer: abs(f - fs*round(f/fs))
unit: kHz
tolerance: 0.5%

### At what frequency does it appear?

::: misses
- [any] The distance to the nearest multiple of {fs} kHz.
:::
:::

::: part
answer: fs/2
unit: kHz
tolerance: 0.5%

### Below what frequency must a tone be to appear as itself?

::: misses
- [any] Half the sample rate.
:::
:::
:::

::: check
kind: parts
given: B = 4 | 15 | 20; g = 0.5 | 1 | 4

## A signal occupies 0 to {B} kHz, and the anti-aliasing filter needs {g} kHz to fall from pass to stop.

::: part
answer: 2*B + g
unit: kHz
tolerance: 0.5%

### What is the lowest usable sample rate?

::: misses
- [2*B] That leaves the filter no room: the first image starts at $f_s - B$.
- [any] $f_s - B \ge B + g$.
:::
:::

::: part
answer: (2*B + g)/2
unit: kHz
tolerance: 0.5%

### What is that rate's Nyquist frequency?

::: misses
- [any] Half of it.
:::
:::
:::

::: check
kind: parts
given: f = 5 | 10 | 20; fs = 44.1 | 48 | 96

## A zero-order hold reconstructs at {fs} kHz.

::: part
answer: 20*log(sin(pi*f/fs)/(pi*f/fs))
unit: dB
tolerance: 0.5%

### How much does it droop at {f} kHz?

::: misses
- [any] $20\log_{10}\operatorname{sinc}(f/f_s)$.
:::
:::

::: part
answer: -20*log(sin(pi*f/fs)/(pi*f/fs))
unit: dB
tolerance: 0.5%

### What boost would a correction filter need there?

::: misses
- [any] The droop, reversed.
:::
:::
:::

::: check
kind: parts
given: fs = 48 | 192; M = 3 | 4 | 6

## A {fs} kHz signal is decimated by {M}.

::: part
answer: fs/(2*M)
unit: kHz
tolerance: 0.5%

### Where should the anti-aliasing filter cut off?

::: misses
- [fs/M] At the new Nyquist frequency: half the new rate.
- [any] $f_s/2M$.
:::
:::

::: part
answer: pi/M
unit: rad
tolerance: 0.5%

### What is that in radians per sample at the original rate?

::: misses
- [any] $\pi/M$.
:::
:::
:::

::: check
kind: parts
given: f = 0.5 | 2 | 3; fs = 8 | 16; L = 3 | 5

## A {f} kHz tone at {fs} kHz is upsampled by {L} with zeros inserted.

::: part
answer: fs - f
unit: kHz
tolerance: 0.5%

### Where is the lowest image?

::: misses
- [any] Mirrored around the old sample rate.
:::
:::

::: part
answer: fs + f
unit: kHz
tolerance: 0.5%

### And the next one above it?

::: misses
- [any] The tone shifted up by the old sample rate.
:::
:::
:::

::: check
kind: parts
given: N = 512 | 2048 | 8192; fs = 8000 | 48000; f = 440 | 997

## An {N}-point DFT runs at {fs} Hz.

::: part
answer: fs/N
unit: Hz
tolerance: 0.5%

### How far apart are its bins?

::: misses
- [any] $f_s/N$.
:::
:::

::: part
answer: f*N/fs
tolerance: 0.5%

### At what fractional bin does a {f} Hz tone fall?

::: misses
- [any] $fN/f_s$.
:::
:::
:::

::: check
kind: parts
given: R = 128 | 500 | 1000; P = 4 | 8; fs = 8 | 44.1

## A {R}-sample record at {fs} kHz is zero-padded to {P} times its length.

::: part
answer: fs*1000/(R*P)
unit: Hz
tolerance: 0.5%

### What is the new bin spacing?

::: misses
- [any] $f_s/(PR)$.
:::
:::

::: part
answer: fs*1000/R
unit: Hz
tolerance: 0.5%

### Roughly how close can two tones be and still be told apart?

::: misses
- [fs*1000/(R*P)] Padding refines the drawing, not the resolution.
- [any] About $f_s/R$: set by the record's length.
:::
:::
:::

::: check
kind: parts
given: L1 = 100 | 300; L2 = 31 | 129

## Sequences of {L1} and {L2} samples are multiplied as DFTs to convolve them.

::: part
answer: L1 + L2 - 1
tolerance: 0

### What is the shortest DFT that gives the linear convolution exactly?

::: misses
- [any] Long enough to hold it: $L_1 + L_2 - 1$.
:::
:::

::: part
answer: 2^ceil(log(L1 + L2 - 1)/log(2))
tolerance: 0

### What power-of-two FFT size would be used?

::: misses
- [any] The next power of two.
:::
:::
:::

::: check
kind: parts
given: d = 0.15 | 0.3 | 0.5

## A tone falls {d} bin from the nearest bin.

::: part
answer: 20*log(sin(pi*d)/(pi*d))
unit: dB
tolerance: 0.5%

### How low does that bin read with no window?

::: misses
- [any] $20\log_{10}\operatorname{sinc}(d)$.
:::
:::

::: part
answer: 20*log(sin(pi*d)/(pi*d) + 0.5*(sin(pi*(d - 1))/(pi*(d - 1)) + sin(pi*(d + 1))/(pi*(d + 1))))
unit: dB
tolerance: 0.5%

### And with a Hann window?

::: misses
- [any] The three-sinc spectrum at {d}.
:::
:::
:::

::: check
kind: parts
given: N = 1024 | 4096; A = 0.2 | 1 | 2.5

## An on-bin tone of amplitude {A} goes into an {N}-point DFT with a Hann window.

::: part
answer: N*A/4
tolerance: 0.5%

### What does its bin read?

::: misses
- [N*A/2] Include the window's coherent gain, 0.5.
- [any] $NA \cdot 0.5/2$.
:::
:::

::: part
answer: A
tolerance: 0.5%

### What amplitude does $2X/(N \cdot 0.5)$ give back?

::: misses
- [any] The true amplitude.
:::
:::
:::

::: check
kind: parts
given: m = 10 | 12 | 16; t = 1 | 10

## An FFT of $N = 2^{\given{m}}$ points takes {t} ns per complex multiplication.

::: part
answer: 2^m/2*m*t/1000
unit: µs
tolerance: 0.5%

### How long do its multiplications take?

::: misses
- [any] $\tfrac N2\log_2N$ multiplications.
:::
:::

::: part
answer: 2^m*2^m*t/1000
unit: µs
tolerance: 0.5%

### And a direct DFT's?

::: misses
- [any] $N^2$ multiplications.
:::
:::
:::

::: check
kind: parts
given: M = 63 | 255; m = 10 | 12

## Overlap-add filters with a {M}-tap filter using $N = 2^{\given{m}}$-point FFTs.

::: part
answer: 2^m - M + 1
tolerance: 0

### How many new samples per block?

::: misses
- [any] $N - M + 1$.
:::
:::

::: part
answer: (4*2^m*m + 4*2^m)/(2^m - M + 1)
tolerance: 0.5%

### How many real multiplications per output sample?

::: misses
- [any] $(4N\log_2N + 4N)/(N - M + 1)$.
:::
:::
:::

::: check
kind: parts
given: a = -9 | -7.5; b = -3 | -2.2; c = -8 | -6; k = 64 | 211; fs = 8000 | 1000; N = 1024 | 512

## A windowed spectrum's log magnitudes (dB) at bins {k} − 1, {k} and {k} + 1 are {a}, {b} and {c}. The DFT has {N} points at {fs} Hz.

::: part
answer: 0.5*(a - c)/(a - 2*b + c)
tolerance: 0.5%

### What fractional offset δ does the parabola give?

::: misses
- [any] $\tfrac12(\alpha - \gamma)/(\alpha - 2\beta + \gamma)$.
:::
:::

::: part
answer: (k + 0.5*(a - c)/(a - 2*b + c))*fs/N
unit: Hz
tolerance: 0.5%

### What is the tone's frequency?

::: misses
- [any] $(k + \delta)f_s/N$.
:::
:::
:::

::: check
kind: parts
given: n = 256 | 1024; fs = 8 | 48; h = 2 | 4

## A spectrogram uses {n}-sample frames at {fs} kHz, a new frame every {n}/{h} samples.

::: part
answer: fs*1000/n
unit: Hz
tolerance: 0.5%

### What is its frequency resolution, about one bin?

::: misses
- [any] $f_s/n$.
:::
:::

::: part
answer: n/h/fs
unit: ms
tolerance: 0.5%

### How often does a new frame come?

::: misses
- [any] The hop, $n/h$ samples.
:::
:::
:::

::: check
kind: parts
given: x = 2 | 4 | 6; fs = 44.1 | 48

## A {fs} kHz signal is upsampled by L = {x}, filtered, then decimated by M = {x} + 1.

::: part
answer: fs*x
unit: kHz
tolerance: 0.5%

### What is the intermediate rate?

::: misses
- [any] L times the input rate.
:::
:::

::: part
answer: fs*x/(x + 1)
unit: kHz
tolerance: 0.5%

### What is the output rate?

::: misses
- [any] $f_s L/M$.
:::
:::
:::
:::
