---
title: "Problem set 6: FFTs and spectral analysis"
heading: "Problem set 6: FFT and Goertzel costs, windowed spectra, the short-time Fourier transform and averaged periodograms"
eyebrow: S7 · Problem set 6
type: problems
---

::: hook
These problems cover lessons 27 to 31: radix-2 operation counts and stages, Goertzel bins and coefficients, scalloping, resolution, coherent gain and processing gain, STFT window lengths, frame rates and chirp resolution, and the variance, resolution and units of power spectrum estimates.
:::

::: pool
pick: 12

::: check
kind: parts
given: N = 128 | 2048 | 32768

## A radix-2 FFT of length {N}.

::: part
answer: log(N)/log(2)
tolerance: 0.001

### Stages?

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

::: part
answer: N/2*log(N)/log(2)
tolerance: 0.5%

### Complex multiplications?

::: misses
- [any] $\frac{N}{2}\log_2N$.
:::
:::

::: part
answer: 2*N/(log(N)/log(2))
tolerance: 0.5%

### Speedup over the direct DFT?

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

::: check
kind: parts
given: f = 941 | 1209 | 1477; N = 205 | 400; s = 8

## A Goertzel detector for {f} Hz with N = {N} at {s} kHz.

::: part
answer: round(f*N/(s*1000))
tolerance: 0

### Bin?

::: misses
- [any] round(fN/f_s).
:::
:::

::: part
answer: 2*cos(2*pi*round(f*N/(s*1000))/N)
tolerance: 0.5%

### Coefficient?

::: misses
- [any] $2\cos(2\pi k/N)$.
:::
:::

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

### How far is the tone from that bin's center?

::: misses
- [any] $|f - kf_s/N|$.
:::
:::
:::

::: check
kind: parts
given: N = 512 | 4096; K = 4 | 12

## A transform of length {N}, needing only {K} bins.

::: part
answer: K*(N + 2)
tolerance: 0.5%

### Goertzel real multiplications?

::: misses
- [any] K(N + 2).
:::
:::

::: part
answer: 2*N*log(N)/log(2)
tolerance: 0.5%

### Radix-2 FFT real multiplications?

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

::: check
kind: parts
given: d = 0.15 | 0.3 | 0.5; N = 256 | 2048; s = 16 | 48

## A tone {d} bin from the nearest bin of an {N}-point FFT at {s} kHz.

::: part
answer: 20*log(sin(pi*d)/(N*sin(pi*d/N)))
unit: dB
tolerance: 0.02

### Rectangular-window scalloping?

::: misses
- [any] $20\log\frac{\sin\pi d}{N\sin(\pi d/N)}$.
:::
:::

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

### Hann resolution?

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

::: check
kind: parts
given: X = 800 | 12000; N = 256 | 4096; c = 0.5 | 0.42; E = 1.5 | 1.73

## A tone on a bin reads |X| = {X} in an {N}-point FFT; the window has coherent gain {c} and ENBW {E}.

::: part
answer: 2*X/(N*c)
tolerance: 0.5%

### Tone amplitude?

::: misses
- [any] $2|X|/(N\cdot\text{CG})$.
:::
:::

::: part
answer: 10*log(N/E)
unit: dB
tolerance: 0.05

### Processing gain?

::: misses
- [any] $10\log(N/\text{ENBW})$.
:::
:::
:::

::: check
kind: parts
given: d = 2 | 10 | 40; s = 8 | 48; M = 4 | 16

## Two tones {d} Hz apart at {s} kHz.

::: part
answer: 2*s*1000/d
tolerance: 0.5%

### Hann record length needed to resolve them?

::: misses
- [any] $2f_s/\Delta f$.
:::
:::

::: part
answer: s*1000/(M*2*s*1000/d)
unit: Hz
tolerance: 0.5%

### Spectral sample spacing after zero-padding that record by {M}?

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

::: check
kind: parts
given: T = 16 | 32 | 64; s = 16 | 44.1; R = 128 | 256

## An STFT with {T} ms Hann windows at {s} kHz, hop {R}.

::: part
answer: T*s
tolerance: 0.5%

### Window length in samples?

::: misses
- [any] $Tf_s$.
:::
:::

::: part
answer: 2000/T
unit: Hz
tolerance: 0.5%

### Frequency resolution?

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

::: part
answer: s*1000/R
tolerance: 0.5%

### Frames per second?

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

::: check
kind: parts
given: R = 800 | 6000 | 40000; T = 10 | 40

## A chirp sweeping {R} Hz/s under a Hann window.

::: part
answer: 1000*sqrt(2/R)
unit: ms
tolerance: 0.5%

### Best window length?

::: misses
- [any] $\sqrt{2/R}$.
:::
:::

::: part
answer: 2*sqrt(2*R)
unit: Hz
tolerance: 0.5%

### Smallest spread?

::: misses
- [any] $2\sqrt{2R}$.
:::
:::

::: part
answer: R*T/1000 + 2000/T
unit: Hz
tolerance: 0.5%

### Spread with a {T} ms window?

::: misses
- [any] RT + 2/T.
:::
:::
:::

::: check
kind: parts
given: N = 512 | 2048; R = 128 | 512

## A real signal's STFT with {N}-point FFTs and hop {R}, Hann window.

::: part
answer: N/(2*R)
tolerance: 0.5%

### Unique complex values per input sample?

::: misses
- [any] N/(2R).
:::
:::

::: part
answer: N/R
tolerance: 0.5%

### Windows overlapping any one sample?

::: misses
- [any] N/R.
:::
:::
:::

::: check
kind: parts
given: N = 32768 | 131072; L = 1024 | 8192; s = 16 | 96

## A {N}-sample record at {s} kHz, {L}-sample Hann segments.

::: part
answer: N/L
tolerance: 0.5%

### Bartlett segments?

::: misses
- [any] N/L.
:::
:::

::: part
answer: 100/sqrt(N/L)
unit: %
tolerance: 0.5%

### Bartlett spread?

::: misses
- [any] $1/\sqrt{K}$.
:::
:::

::: part
answer: floor(2*N/L - 1 + 0.0001)
tolerance: 0

### Welch segments at 50% overlap?

::: misses
- [any] ⌊2N/L⌋ − 1.
:::
:::
:::

::: check
kind: parts
given: P = -130 | -80; E = 1.5 | 1.36; N = 4096 | 32768; s = 48 | 192

## An FFT shows {P} dB per bin; ENBW {E}, N = {N}, {s} kHz.

::: part
answer: E*s*1000/N
unit: Hz
tolerance: 0.5%

### Each bin's noise bandwidth?

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

::: part
answer: P - 10*log(E*s*1000/N)
unit: dB
tolerance: 0.05

### Density, dB per hertz?

::: misses
- [any] Subtract 10 log of that bandwidth.
:::
:::
:::

::: check
kind: parts
given: v = 0.25 | 2; s = 10 | 100; p = 4 | 12

## White noise of variance {v} V² at {s} kHz, estimated to within {p}% spread.

::: part
answer: 2*v/(s*1000)
tolerance: 0.5%

### One-sided PSD, V²/Hz?

::: misses
- [any] $2\sigma^2/f_s$.
:::
:::

::: part
answer: (100/p)^2
tolerance: 0.5%

### Independent segments needed?

::: misses
- [any] $(100/p)^2$.
:::
:::
:::

::: check
kind: parts
given: N = 128 | 1024 | 8192

## Goertzel detectors are compared with a radix-2 FFT of length {N}.

::: part
answer: 2*log(N)/log(2)
unit: bins
tolerance: 0.5%

### Below how many bins is Goertzel cheaper?

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

::: check
kind: parts
given: N = 2048 | 16384; E = 1.36 | 1.73; S = -25 | -12

## A tone {S} dB below white noise is analyzed with an {N}-point FFT and a window of ENBW {E}.

::: part
answer: S + 10*log(N/E)
unit: dB
tolerance: 0.5%

### What SNR does it show in its bin?

::: misses
- [any] Time-domain SNR plus $10\log_{10}(N/\text{ENBW})$.
:::
:::
:::

::: check
kind: parts
given: N = 32768 | 131072; L = 1024 | 4096; s = 16 | 96

## A {N}-sample record at {s} kHz gets Welch analysis with {L}-point Hann segments overlapping by half.

::: part
answer: 2*N/L - 1
unit: segments
tolerance: 0

### How many segments?

::: misses
- [any] $2N/L - 1$.
:::
:::

::: part
answer: 2*s*1000/L
unit: Hz
tolerance: 0.5%

### What resolution?

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