The idea: only the dots survive

A computer cannot store a smooth curve. It samples it: it keeps the value every 1/fs seconds, where fs is the sample rate. Everything between two samples is thrown away. To play the sound or show the picture again, the computer must guess the curve from the dots.

A 9 Hz sine and a 1 Hz sine drawn over one second; 11 samples taken 10 times a second fall on both curves.
9 Hz sampled 10 times a second gives the same dots as an upside-down 1 Hz sine, so the dots cannot tell them apart.

Many sines pass through the same dots. The rebuild (a DAC with a low-pass filter, or your eye) always picks the slowest one. If that is the original tone, sampling worked. If it is a different, slower tone, you got an alias: a false frequency that was never in the input.

Nyquist: more than two samples per cycle

The Nyquist–Shannon sampling theorem says a signal with no frequency at or above fs/2 is fully determined by its samples. fs/2 is the Nyquist frequency. Put the other way round: to capture a tone f you need fs > 2f, more than two samples per cycle (Demo 1: well sampled, 5 samples per cycle).

The inequality is strict. At exactly fs = 2f there are two samples per cycle, and with the wrong phase both land on zero crossings: every sample is 0 and the tone vanishes (Demo 3: exactly 2f).

Folding: where the alias lands

A sine at f and a sine at f − k·fs take the same values at every t = n/fs, because the difference is a whole number of turns per sample. So the samples show the copy closest to zero:

fa=f−fs·round(f/fs)

The result lies between −fs/2 and fs/2. A negative fa is the same speed going backwards; for a sine it means the rebuilt wave is upside down. In the spectrum, sampling makes copies of the tone at every k·fs ± f, and the band 0 … fs/2 sees whichever copy lands in it. A tone just above fs/2 lands just below it: the spectrum folds around fs/2 like paper.

A frequency axis from 0 to 20 Hz with Nyquist at 5 Hz and fs at 10 Hz; a 9 Hz tone folds to 1 Hz, mirrored across fs/2.
With fs = 10 Hz, a 9 Hz tone is 4 Hz above fs/2 and comes out 4 Hz below it, at 1 Hz.
ffssamples per cyclewhat the samples show
2 Hz10 Hz52 Hz ✓
5 Hz10 Hz2all zeros ✗
9 Hz10 Hz1.111 Hz backwards ✗
10 Hz10 Hz10 Hz, a constant ✗
11 Hz10 Hz0.911 Hz forwards ✗
25 kHz44.1 kHz1.7619.1 kHz ✗

The wagon-wheel effect

A film camera samples motion: 24 frames a second. A wheel that turns 0.9 of a turn between frames looks as if it turned 0.1 turn backwards, because that is the smallest move that gives the same picture (Demo 2: alias). At exactly one turn per frame it seems to stand still (Demo 4). The page's wheel has one dot, so it repeats once per turn. A real wheel with 5 identical spokes looks the same after 1/5 of a turn, so it aliases at 5 times the turn rate.

The dot's height is sin(2π f t), the same sine as in the time plot. That is why the wheel and the curve always agree: "backwards" on the wheel is "upside down" on the curve.

The anti-alias filter

An alias cannot be removed after sampling: its samples are exactly those of a real tone at fa. The fix comes before the sampler. An anti-alias filter is a low-pass filter that removes everything at or above fs/2, so nothing can fold. The page's filter passes everything up to 0.45·fs and removes everything from fs/2 up, with a straight line in between; real filters are curves, but the job is the same (Demo 5: anti-alias filter). A camera's motion blur and an optical low-pass filter in front of an image sensor play the same role for pictures.

Audio at 44.1 kHz

People hear up to about 20 kHz. CD audio samples at 44.1 kHz, so Nyquist is 22.05 kHz, just above hearing. Without a filter, a 25 kHz tone (from a bat, a switching power supply or a synthesizer) folds down to 19.1 kHz, inside the audible band (Demo 6). The filter must keep 20 kHz and remove 22.05 kHz: a narrow transition band of about 2 kHz (Demo 7). That steep filter is why modern converters oversample (sample at many times 44.1 kHz with an easy filter, then filter digitally and decimate).

Frequency axis 0 to 30 kHz: the audible band up to 20 kHz, the filter passband to 20 kHz, a transition band to 22.05 kHz, and a 25 kHz tone that would fold to 19.1 kHz.
At 44.1 kHz the filter has only the 20 to 22.05 kHz gap to go from passing everything to passing nothing.
sample rateNyquistused for
8 kHz4 kHztelephone speech (300–3400 Hz)
44.1 kHz22.05 kHzCD audio
48 kHz24 kHzvideo, broadcast, most computers
96 kHz48 kHzstudio recording (easier filters, headroom for processing)

The same folding shows up wherever something is sampled: moiré patterns in photos of fine stripes, jagged edges in images (JPEG compression works on sampled pixels), and the frequency bins of the FFT, which only go up to fs/2.

What the page leaves out

The input is one pure sine with phase 0; real signals are sums of many, and each folds on its own. The rebuild is drawn as the ideal one (a perfect low-pass filter, sinc interpolation over infinitely many samples); a real DAC uses a finite filter and a sample-and-hold step. The anti-alias filter is a straight-line idealization with no phase shift or ripple. Quantization (rounding each sample to 16 or 24 bits), dithering, jitter in the sample clock and band-pass (under-)sampling are not shown.