Sampling Theorem Demo

Explore the Nyquist-Shannon Sampling Theorem and visualize aliasing effects

Nyquist-Shannon Sampling Theorem

To accurately reconstruct a continuous signal, the sampling rate must be at least twice the highest frequency component in the signal (Nyquist Rate).

Nyquist Rate = 2 × Signal Frequency

When sampling below the Nyquist rate, aliasing occurs - the reconstructed signal appears as a different (lower) frequency.

Controls

Sampling rate (50 Hz) is above Nyquist rate (10 Hz) - No aliasing

Nyquist Rate

10 Hz

Samples per Cycle

10

Sampling Ratio

10.0x

Apparent Frequency

5.0 Hz

Visualization

Original Signal
Sample Points
Reconstructed Signal

Understanding the Demo

What is the Nyquist Theorem?

The Nyquist-Shannon Sampling Theorem states that a continuous signal can be perfectly reconstructed from its samples if the sampling rate is greater than twice the highest frequency present in the signal. This minimum sampling rate is called the Nyquist rate.

Key Points:

  • Nyquist Rate = 2 × Maximum Signal Frequency
  • Sampling above the Nyquist rate preserves all information
  • Sampling below the Nyquist rate causes aliasing (information loss)
What is Aliasing?

Aliasing occurs when a signal is sampled below its Nyquist rate. The sampled signal appears to be a different (lower) frequency than the original. This is because there aren't enough samples to capture the true oscillations of the signal.

Example: If you sample a 10 Hz signal at only 15 Hz (below Nyquist rate of 20 Hz), the reconstructed signal will appear to be 5 Hz instead of 10 Hz.

How to Use This Demo

Experiment with different scenarios:

  • Proper Sampling: Set signal frequency to 5 Hz and sampling rate to 50 Hz (10x Nyquist). Notice perfect reconstruction.
  • Minimum Nyquist: Set signal to 5 Hz and sampling to 11 Hz (just above Nyquist). Reconstruction works but barely.
  • Aliasing: Set signal to 10 Hz and sampling to 15 Hz. Watch the reconstructed signal appear as 5 Hz!
  • Severe Aliasing: Set signal to 15 Hz and sampling to 20 Hz. The apparent frequency will be very different.
Real-World Applications
  • Digital Audio: CD-quality audio samples at 44.1 kHz to capture frequencies up to ~22 kHz (human hearing limit)
  • Video: Frame rate must be sufficient to capture motion without aliasing (wagon wheel effect)
  • Communications: Signal bandwidth determines minimum sampling rate for digital transmission
  • Medical Imaging: MRI and CT scans must sample at appropriate rates to avoid artifacts
  • Data Acquisition: Sensor sampling rates must exceed twice the maximum expected signal frequency