Poles and zeros against spectra and covariances, then rebuilding a spoken sentence from white noise alone.
The second lab connects where you put a pole to what the process then sounds like, and ends by compressing speech with that idea.
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.
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.
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.
Back to all engineering work, or the lecture notes.