SMOOTH ×4offx[n]–x[n+1]–x[n+2]–x[n+3]–x[n+4]–x[n+5]–x[n+6]–1import numpy as np2N = 20003rng = np.random.default_rng(1)4x = rng.standard_normal(N)5r = np.correlate(x, x, "full")6R = r[N-1:] / NAVERAGE R[l]–nn+l0.00
010203040-3-2-10123n (sample)x[n]THE SIGNAL x[n]-3-2-10123-3-2-10123x[n]x[n+l]PAIRS (x[n], x[n+l])l = 0-6-4-2024600.250.50.751l (lag, samples)R[l]AUTOCORRELATION R[l]theorymeasuredwhitesmoothed
Coloured parts: what the current step is about; everything else rests in whiteBlocks: noise source, smoothing filter, delay line, multiplier, averager and a Python code cardPlots: the signal x[n], the pairs (x[n], x[n+l]) and R[l] (stems measured, dashed rings theory)The taps read one pair; each product flies to the averager; the dots glide when the lag changesR[l] = average of x[n]·x[n+l] over N = 2000 samples, for white noise (theory σ²·δ[l]) and for 4-tap smoothed noise (theory (4 − |l|)/4). R[l] = E{x[n]·x[n+l]} assumes a (wide-sense) stationary signal. Averaging one long record over n instead of over many draws also assumes the noise is ergodic, which holds for these examples.

Noise and lags

  1. 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.

White noise

Smoothed noise

Rules and code

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 %.