Stationary stochastic processes: Lab 3

Leakage and resolution on a 110 dB spectrum, the solar cycle from sunspots, and a flicker response in EEG.

Repository PythonNumPySciPyMatplotlibJupyter 2026

The third lab is spectral estimation where it is genuinely hard, then two applications on real recordings.

A spectrum that punishes the naive estimator

The test process spans more than 110 dB between its peaks and its notch, which is what makes it a hard case. Averaging 200 realizations shows the bias with the variance taken out of the way.

The plain periodogram reads 16 dB too high across 30 to 50 Hz and misses the notch at 25 Hz by 38 dB, reporting $-13$ dB where the truth is $-52$. Energy from the two large peaks leaks sideways and fills in everything quiet. A Hanning window removes both errors completely and costs nothing but resolution.

Welch's method then trades that resolution for variance, averaging ten overlapping segments. The measured variance ratio came out at 10.3 over 200 realizations, against the factor of 10 the theory predicts. The price shows up immediately: 90 sample segments give a main lobe wider than the 3.9 Hz gap between the two poles, so the peaks broaden and the dip between them fills in.

A solar cycle the frequency grid cannot represent

Two 17 year records of monthly sunspot means. With 204 samples the frequency grid offers periods of only 102 or 204 months, so the raw periodogram has to report one of them and both are wrong.

Zero-padding evaluates the same transform on a grid twenty times denser and finds 124 and 137 months, which is 10.3 and 11.4 years. Nothing was added to the data; the padding only samples the transform more finely. Removing the mean matters too: the squared mean sits one or two bins from the cycle and is ten times larger than it.

A flicker in the EEG

Fifteen seconds of single-channel EEG recorded under a flickering light. A spectrogram with one second windows locates the response in time: 20 Hz and its harmonics at 40 and 60 Hz all lift by about 9 dB between 5 and 10 seconds, then drop back. The 50 Hz mains line sits there throughout, indifferent.

In the 19 channel recording the flicker is at 15 Hz. Welch and the Thomson multitaper method both find it, and multitaper resolves it more sharply, 1.86 Hz of nominal resolution against 4.00. Coherence with the occipital electrode then falls off with distance across the scalp at $r = -0.817$, which is the response appearing where the visual cortex is and fading with every centimetre away from it.


Mean of 200 realizations. The plain periodogram sits 16 dB high above 30 Hz and misses the notch by 38 dB; a Hanning window lands on the truth.
Mean of 200 realizations. The plain periodogram sits 16 dB high above 30 Hz and misses the notch by 38 dB; a Hanning window lands on the truth.
Sunspot records. The raw grid can only offer 102 or 204 months; zero-padding the same data finds 10.3 and 11.4 year cycles.
Sunspot records. The raw grid can only offer 102 or 204 months; zero-padding the same data finds 10.3 and 11.4 year cycles.
The flicker response found in time. All three harmonics lift together between 5 and 10 seconds, while the 50 Hz mains line is unaffected.
The flicker response found in time. All three harmonics lift together between 5 and 10 seconds, while the 50 Hz mains line is unaffected.
Channel O1 of the 19 channel recording: the 15 Hz flicker and its harmonics, by Welch and by the multitaper method.
Channel O1 of the 19 channel recording: the 15 Hz flicker and its harmonics, by Welch and by the multitaper method.