Stationary stochastic processes: Lab 1

Estimation, confidence intervals, and separating a cello from a flute by spectrum alone.

Repository PythonNumPySciPyMatplotlibJupyter 2026

The first of three computer labs for MASC14, Stationary Stochastic Processes. It starts with estimation and ends with a question that sounds like it should be easy and is not.

When the plot and the interval disagree

Means and confidence intervals for white noise, the covariance function of an unknown process, the spectral density of a simulated harmonic signal. The time plots suggest a zero mean. The intervals say otherwise, and that disagreement is the lesson: an offset of 0.2 is invisible against a standard deviation of 0.5, so the eye and the estimator reach opposite conclusions from the same data.

Telling a cello from a flute

Given recordings of a cello and a flute playing the same A, can the two be separated from the spectrum alone?

The obvious candidate fails. Relative overtone strength varies more between two recordings of one instrument than it does between the instruments, so it classifies nothing. Two other features work cleanly: how rough the spectral floor is between harmonics, and how wide the peaks are measured 20 dB down. Both separate all four recordings with no overlap at all.

Aliasing, heard rather than argued

The lab closes by decimating a melody properly, with an anti-alias filter, and then simply dropping every eighth sample. Below 2 kHz the two are identical. Just under the new Nyquist frequency the aliased version sits 23 dB higher, audible as a faint metallic ring, because the folded frequencies land between the cello's harmonics rather than on them.


A cello playing A4. On the dB scale the noise floor between harmonics is visibly jagged.
A cello playing A4. On the dB scale the noise floor between harmonics is visibly jagged.
The same note on a flute. The floor is smooth and the peaks are broader: the two features that separate the instruments.
The same note on a flute. The floor is smooth and the peaks are broader: the two features that separate the instruments.
Spectrogram of a cello melody. Each note is a stack of evenly spaced harmonics, and the lowest stripe traces the tune.
Spectrogram of a cello melody. Each note is a stack of evenly spaced harmonics, and the lowest stripe traces the tune.
melody2 decimated properly, with the anti-alias filter.
melody2 decimated properly, with the anti-alias filter.
The same signal with every eighth sample simply dropped. Energy folds back under the Nyquist frequency, 23 dB above where it should be.
The same signal with every eighth sample simply dropped. Energy folds back under the Nyquist frequency, 23 dB above where it should be.