Chapter 6Sampling & Aliasing

Computers can't store a continuous wave — only a list of numbers snapped at regular intervals. That's sampling. Sample too slowly for how fast the signal wiggles, and something strange happens: a fast wave disguises itself as a slow one.

Drag the upper half of the chart to change the signal's frequency. Drag the lower half (near the sample dots) to change the sample rate.

True continuous signal Samples taken What the samples alone suggest

The Nyquist rule

Nyquist–Shannon sampling theorem
$$ f_s > 2 f_{\text{max}} $$

To capture a signal faithfully, you must sample at more than twice its highest frequency. Half the sample rate, $f_s / 2$, is called the Nyquist frequency — the fastest wiggle that sample rate can ever correctly represent.

What "aliasing" means

When the true signal is faster than the Nyquist frequency, the samples are too sparse to tell the difference between it and a much slower wave that happens to pass through the exact same sample points. The reconstruction (orange, above) locks onto that slower impostor — an alias. The apparent frequency you get is:

Aliased frequency
$$ f_{\text{alias}} = \left| f_{\text{signal}} - f_s \cdot \operatorname{round}\!\left(\frac{f_{\text{signal}}}{f_s}\right) \right| $$
This is exactly why old film wagon wheels appear to spin backwards, why audio must be sampled above 40 kHz (twice the ~20 kHz limit of human hearing — hence 44.1 kHz CDs), and why camera sensors need an anti-aliasing filter. It's the same formula every time.