Nyquist-Shannon Sampling Theorem: Aliasing Visualized

simulator intermediate ~8 min
Loading simulation...
No aliasing — sampling at 12 Hz captures 5 Hz cleanly

With a 5 Hz signal sampled at 12 Hz, the Nyquist criterion (fs > 2f = 10 Hz) is satisfied. The signal can be perfectly reconstructed from its samples.

Formula

f_Nyquist = f_s / 2 (maximum recoverable frequency)
f_alias = |f_signal − round(f_signal / f_s) × f_s|
Oversampling ratio = f_s / (2 × f_max)

The Fundamental Limit of Digital Recording

In 1949, Claude Shannon proved that a continuous signal can be perfectly captured by discrete samples — but only if you sample fast enough. Specifically, the sampling rate must exceed twice the highest frequency in the signal. This elegant result underpins every digital system: CDs, digital cameras, MRI scanners, and seismographs all obey this one theorem.

When Sampling Goes Wrong: Aliasing

Sample too slowly and something strange happens — high frequencies masquerade as low frequencies. This is aliasing, and you have seen it in action: wagon wheels appearing to spin backwards in movies, or moiré patterns on striped shirts on television. The simulator above lets you watch aliasing emerge as you lower the sampling rate below the Nyquist limit.

Perfect Reconstruction

When the Nyquist criterion is satisfied, Shannon showed that sinc interpolation can reconstruct the original continuous signal exactly from its discrete samples. In practice, real systems use approximations (linear or polynomial interpolation), but the theoretical guarantee of perfect reconstruction is what makes digital audio sound identical to the analog original.

From Theory to Practice

CD audio uses 44,100 samples per second — just over twice the 20 kHz upper limit of human hearing. Telephone systems sample at 8,000 Hz for the 4 kHz voice band. Radar systems, medical imaging, and software-defined radio all choose their sampling rates based on Shannon's theorem. Getting it wrong means permanent, irrecoverable information loss.

FAQ

What is the Nyquist-Shannon sampling theorem?

The theorem states that a bandlimited signal can be perfectly reconstructed from its samples if the sampling rate is at least twice the highest frequency component. This minimum rate (2f_max) is called the Nyquist rate.

What is aliasing and why does it occur?

Aliasing occurs when a signal is sampled below the Nyquist rate. Higher frequencies fold back into lower frequencies, creating false (alias) components that cannot be distinguished from real ones. This is why audio CDs sample at 44.1 kHz — to capture frequencies up to 22.05 kHz.

Why do digital cameras have anti-aliasing filters?

Camera sensors sample a continuous image at discrete pixel locations. Without an anti-aliasing filter, fine patterns like fabric weaves or brick walls can produce moiré patterns — visual aliasing artifacts that appear as false colors or wavy lines.

Can you recover an aliased signal?

No. Once aliasing has occurred, the original signal cannot be recovered because the alias and original are indistinguishable in the sampled data. Prevention through proper sampling rate or anti-aliasing filters is the only solution.

Sources

Embed

<iframe src="https://homo-deus.com/lab/signal-processing/sampling-theorem/embed" width="100%" height="400" frameborder="0"></iframe>
View source on GitHub