Sampling Theorem: Definition, Example, and Applications
sampling theorem states that a continuous signal can be perfectly reconstructed from its samples if it is sampled at a rate greater than twice its highest frequency, called the Nyquist rate. This ensures no loss of information during conversion from analog to digital.How It Works
Imagine you want to capture a smooth wave, like a sound or light signal, using snapshots taken at regular intervals. The sampling theorem tells us how often these snapshots (samples) must be taken to capture the wave perfectly without missing any details.
If you take snapshots too slowly, you might miss important changes in the wave, causing a distorted or incorrect picture when you try to rebuild it. But if you take snapshots fast enough—specifically, more than twice the highest frequency in the wave—you can reconstruct the original wave exactly from those snapshots.
This is like watching a flipbook animation: if you flip the pages too slowly, the motion looks jumpy or wrong, but if you flip fast enough, the motion looks smooth and natural. The sampling theorem sets the minimum speed to flip the pages to see the true motion.
Example
This example shows how to sample a simple sine wave and then reconstruct it using the sampling theorem concept.
import numpy as np import matplotlib.pyplot as plt # Original continuous signal: sine wave with frequency 5 Hz fs_continuous = 1000 # High sampling rate to simulate continuous t_continuous = np.linspace(0, 1, fs_continuous, endpoint=False) signal_continuous = np.sin(2 * np.pi * 5 * t_continuous) # Sampling rate (must be >= 2 * 5 = 10 Hz) fs_sample = 20 # Sampling at 20 Hz # Sampled signal n_samples = int(fs_sample * 1) # number of samples in 1 second sample_times = np.linspace(0, 1, n_samples, endpoint=False) sampled_signal = np.sin(2 * np.pi * 5 * sample_times) # Plot plt.figure(figsize=(10, 4)) plt.plot(t_continuous, signal_continuous, label='Original Signal (Continuous)') plt.stem(sample_times, sampled_signal, linefmt='r-', markerfmt='ro', basefmt='k-', label='Sampled Signal') plt.title('Sampling a 5 Hz Sine Wave at 20 Hz') plt.xlabel('Time (seconds)') plt.ylabel('Amplitude') plt.legend() plt.grid(True) plt.show()
When to Use
The sampling theorem is essential when converting real-world analog signals (like sound, light, or sensor data) into digital form for computers to process. It ensures that the digital version keeps all the important information without distortion.
Use it when designing systems like audio recorders, digital cameras, medical imaging devices, or any application where signals must be digitized and later reconstructed or analyzed.
Failing to sample fast enough causes aliasing, where different signals become indistinguishable, leading to errors and poor quality.
Key Points
- The sampling rate must be greater than twice the highest frequency in the signal (Nyquist rate).
- Sampling below this rate causes aliasing and loss of information.
- The theorem allows perfect reconstruction of the original continuous signal from discrete samples.
- It is fundamental in digital signal processing and communication systems.