Noise and Spectral Estimation: Periodogram and Welch
An amplifier's datasheet says its output noise is . You record its output, take an FFT and get a jagged carpet whose height depends on how many points you used: double the record length and every bin drops by , yet the noise has not changed. Tones and noise behave differently in an FFT, and noise needs two things a plain FFT does not give: a density scaling (volts per root hertz), and averaging, because a single FFT of noise is itself a random variable with scatter in every bin. This lesson covers the periodogram, Welch's method, units, and how to read a tone and a noise floor from the same spectrum. Background: Power Spectrum for the theory and Spectrum Analysers for the instrument with its resolution bandwidth.
Power spectral density
For a stationary random signal the meaningful quantity is the power spectral density (PSD) , in : the power per unit bandwidth. Its integral over a band gives the mean-square voltage in that band, and its square root is the noise density in that datasheets quote:
Contrast this with a tone: a sinusoid's power sits at one frequency, so its height in a power spectrum (in , scaling='spectrum') is independent of the bin width, while noise in the same plot scales with the bin's equivalent noise bandwidth . In a density plot it is the other way round: noise is flat and the tone's height grows with . Neither view is wrong; you must just say which you show.
The periodogram and its problem
The periodogram is the scaled squared magnitude of one windowed FFT:
It is unbiased for white noise, but its standard deviation equals its mean, whatever is: more samples give more bins, not smoother ones. Welch's method splits the record into overlapping segments (typically overlap, Hann window), computes a periodogram of each and averages them. The scatter falls roughly as ; the price is resolution, since each segment is shorter (Resolution).
Worked example: an amplifier's noise floor and a test tone
Given: an amplifier output digitised at for samples (): white noise of rms over to plus a peak test tone at .
Find: the noise density, the noise in a band, the tone's rms value, and the scatter of a single periodogram versus Welch with 1000-point segments.
Solve: , density . In : rms. The tone is rms. Welch with 1000-point segments ( bins, so the tone falls exactly on a bin) and overlap uses segments; the scatter should drop from about to roughly (overlapping Hann segments are not fully independent, but overlap loses little).
Check: the program estimates all four.
import numpy as np
from scipy import signal
rng = np.random.default_rng(11)
fs, N = 10_000, 65_536
t = np.arange(N) / fs
x = 1e-3 * rng.standard_normal(N) + 10e-3 * np.sin(2 * np.pi * 1000 * t)
f1, P1 = signal.periodogram(x, fs, window="hann") # one long periodogram, V^2/Hz
f2, P2 = signal.welch(x, fs, window="hann", nperseg=1000) # 50 % overlap by default
noise1 = (f1 > 200) & (np.abs(f1 - 1000) > 50) & (f1 < 4800)
noise2 = (f2 > 200) & (np.abs(f2 - 1000) > 50) & (f2 < 4800)
for name, f, P, m in (("periodogram", f1, P1, noise1), ("Welch 1000", f2, P2, noise2)):
print(f"{name:12s}: density {1e6 * np.sqrt(np.mean(P[m])):.2f} uV/rtHz, "
f"scatter (std/mean) {np.std(P[m]) / np.mean(P[m]):.3f}, bin width {f[1]:.3f} Hz")
print(f"segments averaged: {1 + (N - 1000) // 500}")
band = (f2 >= 2000) & (f2 < 2100)
print(f"noise in 2000..2100 Hz: {1e6 * np.sqrt(np.sum(P2[band]) * (f2[1] - f2[0])):.0f} uV rms (expected 141)")
f3, S3 = signal.welch(x, fs, window="hann", nperseg=1000, scaling="spectrum") # V^2 per bin: tones read right
print(f"tone from 'spectrum' scaling: {1e3 * np.sqrt(S3.max()):.2f} mV rms at {f3[np.argmax(S3)]:.1f} Hz")periodogram : density 14.15 uV/rtHz, scatter (std/mean) 1.007, bin width 0.153 Hz
Welch 1000 : density 14.13 uV/rtHz, scatter (std/mean) 0.089, bin width 10.000 Hz
segments averaged: 130
noise in 2000..2100 Hz: 138 uV rms (expected 141)
tone from 'spectrum' scaling: 7.07 mV rms at 1000.0 Hz
Both estimates agree on the density, but the single periodogram's bins scatter by while Welch's scatter by . The band integral gives against the expected (ten bins of a noisy estimate), and the 'spectrum' scaling reads the tone's rms value, , directly. Had the tone fallen between bins it would read up to low, the Hann scalloping loss.
Reading a real noise spectrum
import numpy as np
from scipy import signal
import matplotlib.pyplot as plt
# Amplifier-like noise: white floor plus 1/f (flicker) noise below a 100 Hz corner, plus 50 Hz hum
rng = np.random.default_rng(4)
fs, N = 10_000, 2**16
white = rng.standard_normal(N)
F = np.fft.rfftfreq(N, 1 / fs)
shape = np.sqrt(1 + 100 / np.maximum(F, 1.0)) # density^2 rises as 1/f below 100 Hz
pink = np.fft.irfft(np.fft.rfft(white) * shape, N)
x = 14.14e-6 * np.sqrt(fs / 2) * pink + 2e-3 * np.sin(2 * np.pi * 50 * np.arange(N) / fs)
f, P = signal.welch(x, fs, nperseg=4096)
d = np.sqrt(P)
for fq in (10, 100, 1000):
k = np.argmin(abs(f - fq))
print(f"density at {fq:5d} Hz: {1e6 * np.median(d[k - 2:k + 3]):6.1f} uV/rtHz")
plt.figure(figsize=(7, 3))
plt.loglog(f[1:], 1e6 * d[1:])
plt.xlabel("f (Hz)"); plt.ylabel("uV/sqrt(Hz)"); plt.title("Welch PSD: 1/f region, white floor, 50 Hz hum")
plt.tight_layout(); plt.show()density at 10 Hz: 51.9 uV/rtHz
density at 100 Hz: 20.3 uV/rtHz
density at 1000 Hz: 15.2 uV/rtHz
On a log-log plot, white noise is flat, flicker noise power grows by per decade towards low frequencies ( in density), and the hum is a spike whose height depends on the segment length because it is a tone, not noise. The model's corner frequency is , where flicker and white noise are equal and the density is (the estimate reads ); at the model gives and the estimate , within the scatter of the few low-frequency bins. The corner is a standard op-amp parameter (Noise).
Practical rules
- Pick
npersegfrom the resolution you need ( for Hann), then use the longest record you can afford to get many segments. - Use
scaling='density'for noise,scaling='spectrum'for tones, and say which. - Use
detrend(default'constant') or remove the mean, or DC leaks into the lowest bins. - To compare with a spectrum analyser, convert: noise power in its resolution bandwidth (and the analyser's own noise-bandwidth corrections).
- Report or , never "dB" alone.
Guided lab: the noise floor of an audio interface
Hand calculation. An ideal 16-bit converter with full scale has , quantisation noise rms, spread over at : .
Simulation. Replace x in the first program by q * np.round(1e-3 * rng.standard_normal(N) / q) with q = 2 / 65536 and see that the noise you add dominates; then set the noise to zero and a tiny tone with dither to see the quantisation floor.
What you would measure. Short the interface's input (or terminate it with ), record 10 s at and run Welch with nperseg=4096. Real interfaces are usually above the ideal quantisation floor because of analog noise; expect a flat floor of order to (consult your device's dynamic-range specification), mains-related lines at or and harmonics if a laptop charger is attached, and a rise below a few tens of hertz. Repeat with only the battery: the lines usually shrink. Welch's estimate of the floor scatters by about for segments.
Hazards and safe setup. Nothing but the interface and a shorting plug or a resistor; run the laptop from its battery if you want to see the difference, and never open a charger.
Pitfalls
- Reading noise from an amplitude spectrum and quoting it in volts (it depends on the bin width).
- Expecting a longer single FFT to give a smoother noise floor.
- Comparing densities computed with different windows without the ENBW correction (Welch does it for you; a hand-rolled FFT does not).
- Treating mains hum as noise: it is a tone and must be read with the spectrum scaling.
Practice
- White noise of rms is sampled at . What is its one-sided density?
- A density of is integrated over to . What rms noise results?
- You average Welch segments. Roughly how much does a bin of the estimate scatter?
Answer
- , so .
- rms.
- About (a little more with overlapping Hann segments), i.e. about .
Test yourself
The unit of a noise density on a datasheet is
- V
- V/Hz
- dB
Doubling the length of a single periodogram of white noise
- halves the scatter of each bin
- leaves the scatter of each bin at about 100 %
- halves the density
- doubles the density
White noise of 1 mV rms sampled at 10 kSa/s has a one-sided density of
The price of averaging more Welch segments from a fixed record is
- more bias
- poorer frequency resolution
- a higher noise floor
- aliasing