---
title: Problem set 5
heading: "Problem set 5: sampling, rate changes, the DFT and the FFT"
eyebrow: C9 · Problem set 5
type: problems
---

::: hook
These problems use lessons 21 to 27: the sampling theorem, aliasing and reconstruction, quantization and dither, changing sample rates, the DFT, windows and leakage, spectrograms, and the FFT with fast convolution. Aliased frequencies are given between 0 and half the sample rate.
:::

::: pool
pick: 12

::: check
kind: parts
given: f = 1300 | 2700 | 3600; fs = 2000 | 5000

## A {f} Hz tone is sampled at {fs} Hz with no anti-aliasing filter.

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

### Where does it appear?

::: misses
- [any] Subtract the nearest multiple of $f_s$.
:::
:::

::: part
answer: 2*f
unit: Hz
tolerance: 0.5%

### What sample rate would the tone need, at the very least, to be captured as itself?

::: misses
- [f] The rate must exceed twice the frequency.
- [any] Not yet. 2f.
:::
:::
:::

::: check
kind: parts
given: B = 18 | 20; fs = 44.1 | 48 | 96; f = 5 | 15

## Audio up to {B} kHz is sampled at {fs} kHz and played through a zero-order hold.

::: part
answer: fs - 2*B
unit: kHz
tolerance: 0.5%

### How wide is the guard band for the anti-aliasing filter?

::: misses
- [any] $(f_s - B) - B$.
:::
:::

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

### How much does the hold droop at {f} kHz?

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

::: check
kind: parts
given: f = 2 | 6; fs = 16 | 40

## A DAC at {fs} kHz outputs a {f} kHz tone.

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

### Where is the lowest image?

::: misses
- [any] $f_s - f$.
:::
:::

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

### Where is the image just below $2f_s$?

::: misses
- [any] $2f_s - f$.
:::
:::
:::

::: check
kind: parts
given: wc = 0.2 | 0.6 | 1.5; fs = 10 | 48

## A digital filter cuts off at ω = {wc} rad and runs at {fs} kHz.

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

### What analog cutoff does it give?

::: misses
- [any] $\omega_cf_s/2\pi$.
:::
:::

::: part
answer: wc*fs/pi
unit: kHz
tolerance: 0.5%

### What would the same coefficients give at twice the sample rate?

::: misses
- [any] The cutoff scales with $f_s$.
:::
:::
:::

::: check
kind: parts
given: fs = 48 | 192; M = 3 | 8; f = 9 | 20

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

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

### What is the new Nyquist frequency?

::: misses
- [fs/M] That's the new sample rate; Nyquist is half of it.
- [any] Not yet. $f_s/2M$.
:::
:::

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

### Without a filter, where does a {f} kHz tone end up?

::: misses
- [any] Fold into 0 to the new Nyquist frequency.
:::
:::
:::

::: check
kind: parts
given: w0 = 0.4 | 0.9; L = 2 | 5

## A tone at ω = {w0} is interpolated by {L}.

::: part
answer: w0/L
unit: rad
tolerance: 0.5%

### Where is the tone at the new rate?

::: misses
- [any] $\omega_0/L$.
:::
:::

::: part
answer: L - 1
tolerance: 0

### Between 0 and 2π, images come in pairs centered on the nonzero multiples of 2π/L. How many pairs are there?

::: misses
- [any] L − 1 copies of the pair, centered at multiples of 2π/L.
:::
:::
:::

::: check
kind: parts
given: fs = 8 | 22.05; L = 3 | 4; M = 2 | 5; osr = 8 | 128

## A {fs} kHz signal is resampled by {L}/{M}; separately, a converter oversamples by {osr}.

::: part
answer: fs*L/M
unit: kHz
tolerance: 0.5%

### What is the resampled rate?

::: misses
- [any] $f_sL/M$.
:::
:::

::: part
answer: 10*log(osr)/log(10)
unit: dB
tolerance: 0.5%

### How much does oversampling cut the in-band quantization noise?

::: misses
- [any] $10\log_{10}$ OSR.
:::
:::
:::

::: check
kind: parts
given: fs = 10000 | 48000; N = 500 | 4096; f = 1200 | 2500

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

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

### How far apart are the bins?

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

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

### At what bin number does {f} Hz fall?

::: misses
- [any] f over the spacing.
:::
:::
:::

::: check
kind: parts
given: A = 0.5 | 3; N = 128 | 1024; k = 7 | 40

## A real cosine of amplitude {A} sits exactly on bin {k} of an {N}-point DFT.

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

### How big is bin {k}?

::: misses
- [any] AN/2.
:::
:::

::: part
answer: N - k
tolerance: 0

### Which other bin is equally big?

::: misses
- [any] N − k.
:::
:::
:::

::: check
kind: parts
given: a = 2 | 1; b = -1 | 3; c = 4 | 2; d = 3 | -2

## x = [{a}, {b}, {c}, {d}] is circularly convolved (N = 4) with h = [1, 0, 0, 1].

::: part
answer: a + b
tolerance: 0

### What is $y_c[0]$?

::: misses
- [a] h[3] = 1 picks up x[1] at n = 0: $x[1]h[(0 - 1) \bmod 4] = x[1]h[3]$.
- [any] Not yet. $\sum_k x[k]h[(0 - k) \bmod 4]$.
:::
:::

::: part
answer: d + a
tolerance: 0

### What is $y_c[3]$?

::: misses
- [any] $x[3]h[0] + x[0]h[3]$.
:::
:::
:::

::: check
kind: parts
given: m = 9 | 12 | 15

## An FFT has $N = 2^{\given{m}}$ points.

::: part
answer: 2^(m - 1)*m
tolerance: 0.5%

### How many complex multiplications does it need?

::: misses
- [any] $\frac N2\log_2N$.
:::
:::

::: part
answer: 2^(m + 1)/m
tolerance: 0.5%

### How many times fewer than the direct DFT is that?

::: misses
- [any] $2N/\log_2N$.
:::
:::
:::

::: check
kind: parts
given: N = 1024 | 8192; M = 129 | 1025; S = 50000 | 2000000

## Overlap-add filters {S} samples through a {M}-tap filter with {N}-point FFTs.

::: part
answer: N - M + 1
tolerance: 0

### How many new samples per block?

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

::: part
answer: M - 1
tolerance: 0

### By how many samples do neighboring blocks' outputs overlap?

::: misses
- [any] The filter's tail: M − 1.
:::
:::
:::

::: check
kind: parts
given: d = 0.2 | 0.35 | 0.5

## A tone is {d} bin off the nearest DFT 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] Three sincs: $\operatorname{sinc}(d) + \tfrac12[\operatorname{sinc}(d - 1) + \operatorname{sinc}(d + 1)]$.
:::
:::
:::

::: check
kind: parts
given: N = 2048 | 8192; A = 0.5 | 3

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

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

### What does its bin read?

::: misses
- [N*A/2] The window's coherent gain halves it.
- [any] $NA/4$.
:::
:::

::: part
answer: 20*log(0.5)
unit: dB
tolerance: 0.5%

### By how many decibels is that below the rectangular window's reading?

::: misses
- [any] The coherent gain, 0.5, in dB.
:::
:::
:::

::: check
kind: parts
given: fs = 8000 | 48000; N = 512 | 4096

## An {N}-point DFT at {fs} Hz is used with a Hann window.

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

### About how close can two equal tones be and still be resolved?

::: misses
- [fs/N] Hann's main lobe is twice as wide as the rectangular window's.
- [any] About two bins.
:::
:::

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

### What is each bin's noise bandwidth?

::: misses
- [any] 1.5 bins for Hann.
:::
:::
:::

::: check
kind: parts
given: N = 10 | 12 | 16; a = 0.5 | 0.1; M = 4 | 16

## An ideal {N}-bit converter digitizes a sine at {a} of full scale and oversamples by {M}.

::: part
answer: 6.02*N + 1.76 + 20*log(a)
tolerance: 0.5%

### What's its SQNR before filtering, in dB?

::: misses
- [6.02*N + 1.76] Subtract the signal's drop below full scale.
- [any] Not yet. $6.02N + 1.76 + 20\log_{10}a$.
:::
:::

::: part
answer: 6.02*N + 1.76 + 20*log(a) + 10*log(M)
tolerance: 0.5%

### And after filtering to the signal band?

::: misses
- [6.02*N + 1.76 + 20*log(a) + 20*log(M)] Noise power falls by $M$: add $10\log_{10}M$.
- [any] Not yet. Add $10\log_{10}M$.
:::
:::

::: right
Right. Gain ahead of the converter and oversampling both buy SNR; only one costs sample rate.
:::
:::

::: check
given: fs = 8 | 16 | 48; L = 256 | 1024; N = 16000 | 48000
answer: floor((N - L)/(L/2)) + 1
tolerance: 0.1%

## A {N}-sample recording at {fs} kHz is cut into Hann frames of {L} samples at 50% overlap. How many frames are there?

::: right
Right: {answer}, each {L} samples long.
:::

::: misses
- [floor(N/L)] Frames start every $L/2$ samples.
- [any] Not yet. $\lfloor(N - L)/(L/2)\rfloor + 1$.
:::
:::
:::
