---
title: Power spectrum estimation
heading: The power spectral density of random signals, the periodogram and why it doesn't improve with length, averaging by Bartlett and Welch, confidence intervals and units
eyebrow: S7 · Lesson 31 · Power spectrum estimation
xp: 50
---

::: hook
Noise has a spectrum too, its power spectral density, and measuring it is one of the most common jobs in signal processing: the noise floor of a receiver, the vibration spectrum of a machine, the phase noise of an oscillator. The obvious estimate, the squared magnitude of one long FFT, has a surprising flaw. However long the record, each bin of it fluctuates by 100% of its own value, so the plot looks like grass. Averaging the spectra of many shorter segments tames the fluctuation, at the cost of resolution, and that trade between variance and resolution is the whole art of spectrum estimation.
:::

::: play
- A histogram of single-bin power estimates for white noise of PSD 1, each the average of K independent periodograms (dashed: the theoretical density, a gamma distribution).
- With K = 1 the estimate is exponentially distributed: its standard deviation equals its mean, so individual readings range over more than 10 dB.
- Averaging K segments narrows the spread to $1/\sqrt{K}$ of the mean. Eight segments bring it to 35%.
:::
:::

```sim plot
view: random
x: v = 0..5
slider: K = 1..8 = 1 step 1
sample: (-ln(1 - rand(1)) + step(K - 1.5)*(-ln(1 - rand(1))) + step(K - 2.5)*(-ln(1 - rand(1))) + step(K - 3.5)*(-ln(1 - rand(1))) + step(K - 4.5)*(-ln(1 - rand(1))) + step(K - 5.5)*(-ln(1 - rand(1))) + step(K - 6.5)*(-ln(1 - rand(1))) + step(K - 7.5)*(-ln(1 - rand(1))))/K | mean: M | sd: S
trials: 4000
bins: 50
density: K^K*v^(K - 1)*exp(-K*v)/(K - 1)!
readout: mean = M
readout: standard deviation = S
readout: theory, 1/√K = 1/sqrt(K)
```

::: predict
## A periodogram of white noise from a 1,024-sample record is too noisy. What happens if the record is made 16 times longer and one 16,384-point FFT is taken?

- [ ] The fluctuations shrink by 4 times
- [ ] They shrink by 16 times
- [x] They stay at 100%; only the bins get narrower
- [ ] They get worse

::: reveal
They stay at 100%. A longer FFT gives more, narrower bins, each still an exponentially distributed estimate whose standard deviation equals its mean. The extra data is spent on resolution. Splitting the long record into 16 segments of 1,024 and averaging their periodograms keeps the original resolution and cuts the fluctuation to $1/\sqrt{16}$ = 25%.
:::
:::

::: nameit
## The power spectral density

For a wide-sense stationary signal with autocorrelation $\phi_{xx}[m] = E\{x[n + m]x^*[n]\}$, the PSD is its DTFT, $P_{xx}(\omega) = \sum_m\phi_{xx}[m]e^{-j\omega m}$ (Wiener–Khinchin), and the average power is $\frac{1}{2\pi}\int P_{xx}\,d\omega$. White noise of variance σ² has a flat PSD; in physical units the one-sided density is $2\sigma^2/f_s$ per hertz.

## The periodogram

$I(\omega) = \frac{1}{NU}|V(e^{j\omega})|^2$ for the windowed segment v = wx, with $U = \frac{1}{N}\sum w^2$. It's asymptotically unbiased, but its variance doesn't fall with N: for white noise each bin is exponential, standard deviation equal to the mean.

## Averaging

- **Bartlett**: K non-overlapping segments, average their periodograms; variance falls by K, standard deviation by $\sqrt{K}$, while resolution worsens by K for a fixed record.
- **Welch**: windowed segments overlapping by 50%; a record that gives K plain segments gives about 2K − 1 overlapped ones, nearly independent with a Hann window, so the variance falls further at the same resolution.
- **Confidence**: an average of K independent periodograms is $\chi^2$ with 2K degrees of freedom. For K = 8, the true PSD lies between 0.555 and 2.32 times the estimate with 95% confidence, −2.6 to +3.6 dB.

## Units

A bin's power (in V² per bin) becomes a density by dividing by its noise bandwidth, ENBW × $f_s/N$ hertz (lesson 29): $\text{PSD}_\text{dB} = P_\text{bin,dB} - 10\log(\text{ENBW}\,f_s/N)$.
:::

::: example
## A record of 65,536 samples at 48 kHz is analyzed with 4096-point Hann segments, Bartlett style. How many segments, what spread and what resolution?

::: solution
1. **Segments.**
   $$\begin{aligned} K &= \frac{65\,536}{4096} \\ &= 16\ \text{segments} \end{aligned}$$
2. **Spread.**
   $$\begin{aligned} \frac{\sigma}{\mu} &= \frac{1}{\sqrt{16}} \\ &= 25\% \end{aligned}$$
3. **Resolution.** For Hann:
   $$\begin{aligned} \Delta f &= \frac{2 \times 48\,000}{4096}\ \text{Hz} \\ &= 23.4\ \text{Hz} \end{aligned}$$
4. **With overlap.** With 50% overlap (Welch) there would be 31 segments and a spread near 18%, for the same resolution.

**Answer:** 16 segments, a standard deviation of 25% of the mean, and 23.4 Hz resolution.
:::
:::

::: example
## A 4096-point Hann FFT at 48 kHz shows a noise floor of −100 dB (V² per bin). What's the noise density?

::: solution
1. **Bin noise bandwidth.**
   $$\begin{aligned} B &= \frac{1.5 \times 48\,000}{4096}\ \text{Hz} \\ &= 17.6\ \text{Hz} \end{aligned}$$
2. **Density.**
   $$\begin{aligned} N_0 &= -100 - 10\log 17.6 \\ &= -112.4\ \text{dB re 1 V}^2/\text{Hz} \end{aligned}$$
   or about 2.4 µV/√Hz.
3. **Why the bin width matters.** Quoting a "noise floor" without stating the bin width means nothing, since a longer FFT would show a lower floor for the same noise.

**Answer:** −112.4 dB re 1 V²/Hz, about 2.4 µV/√Hz.
:::
:::

::: example
## The 65 536-sample record at 48 kHz is analyzed by Welch's method with 4096-point Hann segments overlapping by half. How many segments, and what spread?

::: solution
1. **Segments.** Half-overlapping segments start every 2048 samples, so
   $$2 \times \frac{65\,536}{4096} - 1 = 31$$
   fit.
2. **Spread if independent.**
   $$\begin{aligned} \frac{\sigma}{\mu} &= \frac{1}{\sqrt{31}} \\ &= 18\% \end{aligned}$$
   against 25% for 16 Bartlett segments.
3. **Correlation.** Overlapped Hann segments are slightly correlated, so the real figure is a little worse, but still better than Bartlett at the same 23.4 Hz resolution.

**Answer:** 31 segments, with a spread a little worse than 18% of the mean.
:::
:::

::: check
given: K = 4 | 10 | 25 | 64
answer: 100/sqrt(K)
unit: %
tolerance: 0.5%

## A Bartlett estimate averages {K} independent periodograms of white noise. What's its standard deviation, as a percentage of its mean?

::: right
Right. $1/\sqrt{K}$ = {answer}%.
:::

::: misses
- [100/K] The variance falls by K; the standard deviation by √K.
- [any] Not yet. Each periodogram has 100% spread; averaging K divides by √K.
:::
:::

::: check
given: p = 5 | 10 | 20
answer: (100/p)^2
tolerance: 0.5%

## How many independent segments must be averaged for the estimate's standard deviation to be {p}% of its mean?

::: right
Right. $1/\sqrt{K} = p/100$ gives K = {answer}.
:::

::: misses
- [100/p] Square it: the spread goes as $1/\sqrt{K}$.
- [any] Not yet. Solve $1/\sqrt{K} = p/100$.
:::
:::

::: check
given: N = 16384 | 65536; K = 4 | 16 | 32; s = 8 | 48
answer: 2*K*s*1000/N
unit: Hz
tolerance: 0.5%

## An {N}-sample record at {s} kHz is split into {K} Hann-windowed segments. What frequency resolution results?

::: right
Right. Segments of N/K samples resolve about $2f_sK/N$ = {answer} Hz.
:::

::: misses
- [2*s*1000/N] That's the resolution of one FFT over the whole record; segments are K times shorter.
- [any] Not yet. Hann resolution is $2f_s/L$ with L = N/K.
:::
:::

::: check
given: P = -120 | -90 | -60; E = 1.36 | 1.5 | 1.73; N = 1024 | 8192; s = 8 | 96
answer: P - 10*log(E*s*1000/N)
unit: dB
tolerance: 0.05

## An {N}-point FFT at {s} kHz with a window of ENBW {E} shows {P} dB per bin. What's the power spectral density, in dB per hertz?

::: right
Right. $P - 10\log(\text{ENBW}\,f_s/N)$ = {answer} dB/Hz.
:::

::: misses
- [P - 10*log(s*1000/N)] Include the window's noise bandwidth.
- [P - 10*log(s*1000)] Divide by the bin's bandwidth, not the whole sample rate.
- [any] Not yet. Divide by the bin's noise bandwidth in hertz.
:::
:::

::: check
given: v = 0.01 | 1 | 4; s = 8 | 44.1 | 1000
answer: 2*v/(s*1000)
unit: V²/Hz
tolerance: 0.5%

## White noise of variance {v} V² is sampled at {s} kHz. What's its one-sided PSD in V²/Hz?

::: right
Right. $2\sigma^2/f_s$ = {answer}.
:::

::: misses
- [v/(s*1000)] That's the two-sided density; the one-sided one counts positive frequencies only, twice as dense.
- [any] Not yet. The power spreads evenly over 0 to $f_s/2$.
:::
:::

::: check
given: N = 32768 | 100000; L = 1024 | 4096
answer: floor(2*N/L - 1 + 0.0001)
tolerance: 0

## A Welch estimate uses {L}-sample segments overlapping by 50% over {N} samples. How many segments fit?

::: right
Right. Segments start every L/2 samples: ⌊2N/L⌋ − 1 = {answer}.
:::

::: misses
- [floor(N/L + 0.0001)] That's without overlap.
- [any] Not yet. Count starting points L/2 apart that leave room for a full segment.
:::
:::

::: check
kind: parts
given: N = 16384 | 65536 | 262144; L = 512 | 2048 | 4096; s = 8 | 48

## A record of {N} samples at {s} kHz is analyzed by Welch's method with {L}-point Hann segments overlapping by half.

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

### How many segments fit?

::: misses
- [N/L] That's without overlap.
- [any] $2N/L - 1$.
:::
:::

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

### What resolution does each segment give?

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

::: check
kind: derivation
vars: v = 0.001..10, s = 1000..200000, K = 1..1000

## White noise of variance v is sampled at s and its PSD estimated by averaging K independent periodograms.

::: step
answer: 2*v/s

### What is its one-sided PSD?
:::

::: step
answer: 2*v/s/sqrt(K)

### What standard deviation does the estimate have?
:::

::: step
answer: 1/sqrt(K)

### What is that as a fraction of the mean?
:::

::: right
Right. Halving the spread takes four times as many segments, and so four times the record or a quarter of the resolution.
:::
:::

::: explain
## Why doesn't a longer FFT make a periodogram of noise smoother?

::: model
Each bin of a periodogram measures the noise power in a band one bin wide, using the data available. Making the FFT longer narrows every bin in proportion, so each bin covers less bandwidth and still sees, in effect, only about two independent random numbers, the real and imaginary parts of its DFT value. The estimate in each bin therefore keeps the same relative randomness, an exponential distribution with standard deviation equal to its mean. The extra data has been spent on resolving finer frequency detail, not on averaging. To reduce the fluctuation, the data must instead be used for averaging, by splitting it into segments or smoothing across neighboring bins, which gives up resolution in exchange.
:::
:::

::: practice

::: check
given: K = 4 | 9 | 16 | 25 | 49 | 100
answer: 100/sqrt(K)
unit: %
tolerance: 0.5%

## Spread with K = {K} averages?

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

::: check
given: P = -110 | -70; E = 1.5 | 1.73; N = 2048 | 16384; s = 16 | 48
answer: P - 10*log(E*s*1000/N)
unit: dB
tolerance: 0.05

## PSD from {P} dB per bin, ENBW {E}, N {N}, {s} kHz?

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

::: check
given: p = 5 | 8 | 10 | 15 | 20 | 25
answer: (100/p)^2
tolerance: 0.5%

## Segments for a {p}% spread?

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