Stationary stochastic processes: Lab 2

Poles and zeros against spectra and covariances, then rebuilding a spoken sentence from white noise alone.

Repository PythonNumPySciPyMatplotlibJupyter 2026

The second lab connects where you put a pole to what the process then sounds like, and ends by compressing speech with that idea.

Four views of one process

Part one is a single reusable function. Give it a numerator and a denominator and it returns the four equivalent descriptions of the same process: the pole-zero map, the spectral density, the covariance function and a realization. Everything after that is moving poles around and watching all four change together.

The pole radius sets memory. At radius 0.5 the covariance has died by lag 10; at 0.98 it is still large at lag 40 and the spectral peak has become a spike. The pole angle sets the oscillation frequency, so a pair at frequency 0.05 gives a covariance with a 20 lag period while one at 0.45 alternates almost every sample. Zeros do the opposite: they carve notches, and a zero placed on top of a pole at the same radius and angle cancels it exactly, leaving white noise.

Rebuilding a sentence from noise

The second half is a simplified LPC decoder, the idea behind GSM speech coding. A recorded sentence is low-pass filtered, decimated from 48 kHz to 8 kHz, and cut into 118 frames of 20 ms. Each frame gets its own AR model, and the sentence is then regenerated from those coefficients driving white noise. No part of the original waveform is kept.

At order 7 the sentence survives at twenty times compression; order 20 resolves four formants around 240, 780, 1860 and 2280 Hz. Choosing the order meant reading the elbows of the final prediction error rather than its global minimum, which falls at 45 parameters for 160 samples and is fitting noise.

Decimating first is what makes the model work at all. Before it, the speech occupies one twelfth of the frequency axis and the models spend their poles describing the filter's own 50 dB cliff instead of the voice.

Where the handout is wrong

Comparing against theory rather than against the manual turned up four errors: a noise variance squared once too often, where taking the modulus squared already supplies it; a mirrored covariance off by one index, leaving a residual at $10^{-3}$ where $10^{-16}$ belongs; a frame one sample short, because MATLAB includes the upper index and Python does not; and the claim that innovation variance always falls with model order, which stops being true past about order 40, once the estimator's divisor has run out of samples.


One AR(2) in four equivalent descriptions. The pole pair at radius 0.9 fixes both the spectral peak at frequency 0.15 and the oscillation period of about 7 lags.
One AR(2) in four equivalent descriptions. The pole pair at radius 0.9 fixes both the spectral peak at frequency 0.15 and the oscillation period of about 7 lags.
Pole radius sets memory. At 0.50 the covariance is gone by lag 10; at 0.98 it is still large at lag 40 and the peak has become a spike.
Pole radius sets memory. At 0.50 the covariance is gone by lag 10; at 0.98 it is still large at lag 40 and the peak has become a spike.
A 20 ms frame of speech after decimation to 8 kHz. AR(6) follows the envelope, AR(20) resolves four formants, marked in yellow.
A 20 ms frame of speech after decimation to 8 kHz. AR(6) follows the envelope, AR(20) resolves four formants, marked in yellow.