Noise and lags
A noise source makes a new random number every sample: w[n]. Each one is drawn on its own, with mean 0 and variance 1. Knowing w[5] tells you nothing about w[6]. We cannot predict noise, but we can describe it.
Pick a lag l: a whole number of samples. Pair each sample x[n] with the one l places later, x[n+l]. Two taps on the delay line read each pair. Autocorrelation asks: are such pairs alike, on average?
White noise
At lag 0 each sample meets itself. Multiply, x[n]·x[n] = x[n]², and average over N = 2000 samples: R[0] = 1.00. That is the mean power of the noise, which equals its variance because the mean is 0.
At lag 1 the neighbours are independent. Their product is as often negative as positive, so the average heads to zero: R[1] = 0.00. The scatter of pairs is a round cloud: x[n] says nothing about x[n+1].
Repeat for every lag. White noise gives one spike at 0 and about zero elsewhere: R[l] = σ²·δ[l], where δ[l] is 1 at l = 0, else 0. The small wiggles, at most 0.01, come from averaging only 2000 samples.
Smoothed noise
Switch on a smoothing filter: y[n] = (w[n] + w[n−1] + w[n−2] + w[n−3]) / 2. Each output adds four independent inputs, so its variance is 4 × ¼ = 1 again. Same power, but the wave now wanders smoothly.
y[n] and y[n+1] share three of their four inputs, so they tend to agree. Most products are positive. Theory says R[1] = ¾ = 0.75; the averager measures 0.76. The scatter cloud tilts along the diagonal.
Sweep the lags. Shared inputs drop 4, 3, 2, 1, 0, so R[l] = (4 − l)/4 falls 1, 0.75, 0.5, 0.25, then 0. After four samples the filter has forgotten. How wide R is tells how long a signal remembers.
Rules and code
R[−l] = R[l]: pairing x[n] with x[n−l] uses the same pairs, read the other way. And |R[l]| ≤ R[0]: nothing matches a signal better than itself. So the plot is mirror-symmetric with its peak at 0.
np.correlate(x, x, "full") forms every lagged sum at once. Slicing from index N−1 keeps lags 0, 1, 2 ..., and dividing by N averages. For white noise numpy prints about 1, then values near 0. (Python 3, numpy.)
A narrow R means a wide spectrum. The power spectral density is the Fourier transform of R (Wiener–Khinchin), so white noise's single spike gives equal power at every frequency. The next lesson builds on this.
The working
# step 1/11 · noise
w[n]: Gaussian, mean 0, variance σ² = 1
a fresh, independent draw each sample
w[0] = −0.50 w[1] = −0.60 ...
the delay line holds x[n] .. x[n+6]
and shifts one place every sample
random signals and noise: see the previous lesson
The noise in the figure is one pseudo-random draw of N = 2000 Gaussian samples (seed 9). A different draw moves each estimate by a few hundredths; the theory values do not move. The averager divides each lagged sum by the number of products, N − l. numpy's line divides by N instead (a biased estimate); for lags up to 6 the two differ by at most 0.3 %.