Nyquist Sampling & Aliasing Demo

Nyquist sampling & aliasing demo

Change the signal and sampling rate, then watch the same story in the waveform, the sample points, the spectrum replicas, and (optionally) sinc reconstruction. Presets match the sampling theorem article: a 10 Hz tone at 50 Hz (safe) and at 12 Hz (aliases to a phase-inverted 2 Hz tone).

Fm is the highest tone frequency in the chosen signal.
Drag through Fs > 2Fm, Fs = 2Fm, and Fs < 2Fm.
At Fs = 2Fm, try φ = 90°: samples can collapse to (near) zero.
x(t) = …
…
Fs—
Fm (max tone)—
Nyquist rate 2Fm—
Nyquist freq Fs/2—
Samples / cycle (at Fm)—
Primary alias (f₁)—

Continuous signal (blue), samples (orange dots), optional reconstructed waveform (green dashed).

Baseband spectrum and replicas centred at k·Fs. Overlap (aliasing) is shaded.

How to use. Start with the safe preset (10 Hz @ 50 Hz), then switch to 12 Hz sampling and watch the orange samples lie on a 2 Hz wave of opposite phase. Open the spectrum panel to see replicas overlap. At Fs = 2Fm, slide phase to 90° to see why equality is not a safe engineering rule. Turn on the anti-alias filter: tones above Fs/2 disappear before sampling, so the replicas no longer pollute the baseband.

Article: Nyquist–Shannon sampling theorem · Related: FFT resolution calculator · Bandpass sampling demo

How to use this demo

Pick a signal, set Fs, and compare the continuous waveform with the orange sample points. The metric strip reports Fm, the Nyquist rate 2Fm, samples per cycle, and the baseband alias of the first tone. Switch the bottom panel between spectrum replicas and sinc reconstruction. At Fs = 2Fm, slide phase to ±90° to see samples collapse — the classic reason equality is not enough in practice.

Try the shareable presets: 10 Hz @ 50 Hz, 10 Hz @ 12 Hz (alias → 2 Hz), Nyquist boundary with φ = 90°.

FAQ

Why does a 10 Hz sine sampled at 12 Hz look like 2 Hz? Sampling creates spectral copies every Fs. The 10 Hz line folds to |10 − 12| = 2 Hz in the baseband, with a sign change that appears as a phase inversion. No post-filter can undo that overlap.

What does the anti-alias filter control show? An ideal low-pass at Fs/2 before the sampler removes tones that would fold. Filtering after sampling cannot separate energy that already sits on top of the baseband copy.

Why can Fs = 2Fm still fail? For a pure sine at the Nyquist frequency, a 90° phase can place every sample at a zero crossing. Ideal theory needs careful conditions at equality; engineering practice keeps Fs strictly above 2Fm and uses a real anti-alias filter.

Related reading