Skip to content
AI360XpertBeta

Sampling Theorem / Nyquist, Aliasing

Sample at least twice the fastest wiggle and the original wave rebuilds exactly. Sample slower and a false slow wave appears that was never there.

Sample a 5 Hz tone at 20 Hz and the rebuild matches; sample it at 6 Hz and a false 1 Hz tone appears
Sample a 5 Hz tone at 20 Hz and the rebuild matches; sample it at 6 Hz and a false 1 Hz tone appears

Why Does This Exist?

Every sensor chooses a rate: audio at 44100 Hz, images at one sample per pixel, logs once per minute. Choose too low and high frequencies do not just blur, they reappear as confident low frequencies that were never in the world. A 5 Hz wobble sampled at 6 Hz returns as a clean 1 Hz wave, and no downstream model can tell the lie from truth.

The sampling theorem draws the line. If the highest frequency present is fmax⁡f_{\max}, sampling at fs≥2fmax⁡f_s \ge 2 f_{\max} preserves everything, and sinc interpolation rebuilds the continuous wave exactly. Below 2fmax⁡2 f_{\max}, frequencies fold: ff masquerades as ∣f−kfs∣|f - k f_s|. This page proves the rule with one 5 Hz tone carried through every section. Frequency language lives in Fourier transform and convolution theorem, fast spectra in discrete Fourier transform and FFT, and localized wiggles in wavelets.

The one idea you need first

A frequency counts cycles per second in Hz. A 5 Hz tone completes 5 cycles each second, period 0.20.2 s. Sampling records the height at spacing 1/fs1/f_s. With fs=20f_s = 20 Hz you keep 4 heights per 5 Hz cycle; with fs=6f_s = 6 Hz you keep only 1.21.2 heights per cycle, below the 2 needed to see up from down.

Think of It Like This

A wagon wheel under a strobe

A wagon wheel spins forward fast while a strobe flashes. Flash twice per spoke pass and you see each spoke advance: true motion. Flash slower than twice per pass and a spoke from the next gap arrives where you expected the old one, so the wheel crawls backward or stands still on film.

Samples are flashes, spokes are wave peaks. The Nyquist rate is twice per pass: fewer flashes invent direction. Where the analogy stops: strobes alias rotation, while sampling aliases any fast wiggle into a slow tone, and the false tone is mathematically exact, not a trick of the eye.

How It Actually Works

Bandlimit the signal to fmax⁡f_{\max}, sample at fsf_s, keep tones below fs/2f_s/2. The Nyquist rate is 2fmax⁡2 f_{\max}: the minimum fsf_s that works. At or above it, the samples determine exactly one bandlimited wave, rebuilt by summing shifted sincs. Below it, true ff and alias ∣f−kfs∣|f - k f_s| share identical samples for integer kk, so the rebuild picks the low one.

In plain words: 2 samples per cycle is the break-even where up and down stay distinguishable. At 1.21.2 samples per cycle, two different waves thread the same dots, and reconstruction chooses the slower impostor.

Worked example

Take a 5 Hz tone, amplitude 1. Nyquist rate is 2×5=102 \times 5 = 10 Hz.

Adequate: fs=20f_s = 20 Hz. Samples per cycle are 20/5=420/5 = 4. The dots trace peak, zero, trough, zero, and sinc rebuilding returns the 5 Hz tone. True equals rebuilt.

Too slow: fs=6f_s = 6 Hz. Samples per cycle are 6/5=1.26/5 = 1.2, below 2. The nearest fold is k=1k = 1: alias is ∣5−6∣=1|5 - 6| = 1 Hz. The dots that the 5 Hz wave leaves at 6 Hz sampling are exactly the dots a 1 Hz wave leaves, so the rebuild reports a slow 1 Hz wobble at full height. Same dots, wrong wave, no warning flag.

Code

Compute the fold for the worked tone with no libraries beyond the standard one.

f_true = 5.0for fs in (20.0, 6.0):    k = round(f_true / fs)  # nearest fold    alias = abs(f_true - k * fs)    print(fs, alias)  # -> 20.0 5.0 and 6.0 1.0

At 20 Hz the fold stays 5 Hz: no alias. At 6 Hz it folds to 1 Hz: the dashed impostor in the diagram. The printout reads 5.0 and 1.0 against the hand computation above.

Watch Out For

Sampling at exactly twice with no margin or filter

The theorem assumes a perfectly bandlimited signal and ideal sinc rebuilding. Real sensors carry noise above fmax⁡f_{\max} and real filters roll off gently, so sampling audio at exactly 2×202 \times 20 kHz folds the 21 kHz hiss into 19 kHz whine. Oversample to 2.22.2 times or higher and put a low-pass anti-alias filter before the sampler, not after.

Downsampling without low-passing first

Taking every fourth pixel or every tenth log row without filtering folds the dropped high frequencies into the kept band: brick walls become rainbow moire, fast spikes become slow drifts. Filter to the new Nyquist fs/4f_s/4 or fs/10f_s/10 first, then drop. If moire appears after a resize, the filter was missing, not the pixels.

The Quick Version

  • Signals below half the sampling rate rebuild exactly; that half rate is the Nyquist frequency.
  • The Nyquist rate is twice the highest frequency present: 10 Hz for a 5 Hz tone.
  • At 20 Hz a 5 Hz tone keeps 4 samples per cycle and rebuilds true.
  • At 6 Hz the same tone keeps 1.2 samples per cycle and returns as a false 1 Hz wave.
  • Filter before sampling and before downsampling, or high frequencies fold into low ones.