Sampling
From continuous to discrete
The real world is continuous. Sound pressure changes smoothly over time. Light intensity varies continuously across space. Voltage on a wire fluctuates without jumps.
But computers are discrete. They can only store numbers, a finite set of values at specific moments in time. To process a signal digitally, we need to capture snapshots: measure the signal's value at regular intervals and store each measurement as a number.
This process is called sampling, and it raises an immediate question: how often do you need to sample to capture all the information in the signal?
Taking Samples
Sampling means measuring a continuous signal x(t) at evenly spaced points in time:
x[n] = x(n · Ts) for n = 0, 1, 2, 3, …
- fs = sample rate, how many samples per second (in Hz)
- Ts = 1/fs = sample period, the time between consecutive samples
- x[n] = the n-th sample, a discrete sequence of numbers
The Nyquist-Shannon Sampling Theorem
In 1949, Claude Shannon proved one of the most important results in information theory:
fs > 2 · fmax
The critical threshold 2·fmax is called the Nyquist rate. Sample faster than this, and you lose nothing. Sample slower, and information is permanently destroyed.
| Application | Max freq | Nyquist rate | Typical fs |
|---|---|---|---|
| Telephone | 3.4 kHz | 6.8 kHz | 8 kHz |
| CD audio | 20 kHz | 40 kHz | 44.1 kHz |
| Professional audio | 20 kHz | 40 kHz | 48 kHz or 96 kHz |
| Ultrasound imaging | 15 MHz | 30 MHz | 40–60 MHz |
Notice that the actual sample rate is always a bit higher than the Nyquist rate. This margin provides a practical safety buffer.
Aliasing: When Sampling Goes Wrong
What happens when you sample too slowly? The high-frequency signal masquerades as a lower-frequency signal. This is called aliasing, where the signal takes on a false identity.
Think of a wagon wheel in a movie: when the camera's frame rate is too low, a wheel spinning forward can appear to spin backward. The high rotation frequency aliases to a lower (and reversed) frequency because of insufficient sampling.
Where Does the Alias Land?
There's a simple rule for computing the alias frequency. A signal at frequency f, sampled at rate fs, appears at:
falias = |f − round(f / fs) · fs|
More intuitively: the alias frequency is how far f is from the nearest integer multiple of fs. All frequencies "fold" into the range [0, fs/2], bouncing back and forth like a ball between the floor and ceiling.
Why This Matters
Sampling is where the analog and digital worlds meet, and getting it wrong has real consequences:
- Audio recording: A mic picks up frequencies above 22 kHz (inaudible). Without an anti-aliasing filter, these alias into the audible range and create harsh, unnatural artifacts.
- Sensor systems: A vibration sensor on a motor must sample faster than twice the highest vibration frequency, or real faults will alias into frequency bins where they look like something else entirely.
- Software-defined radio: Intentional aliasing (called undersampling or bandpass sampling) is sometimes used to shift a high-frequency signal down to a lower frequency, using aliasing as a feature, not a bug.
- Video: Camera frame rates that are too low create the wagon-wheel effect (temporal aliasing). Spatial aliasing causes moiré patterns on fine textures like brick walls or striped shirts.
Frequently Asked Questions
What is the Nyquist theorem?
The Nyquist-Shannon sampling theorem states that to faithfully capture a signal, you must sample at more than twice its highest frequency: fs > 2·fmax. The frequency fs/2 is called the Nyquist frequency. Below this rate, high-frequency content folds back into lower frequencies (aliasing) and the original signal cannot be recovered.
What is aliasing?
Aliasing occurs when a signal is sampled too slowly. Frequencies above the Nyquist limit masquerade as lower frequencies in the sampled data. A classic example: a 12 kHz tone sampled at 10 kHz appears as a 2 kHz tone. The samples are identical for both frequencies, so the original cannot be recovered. Anti-aliasing filters prevent this by removing high frequencies before sampling.
Why was CD audio set to 44.1 kHz?
Human hearing extends to roughly 20 kHz. The Nyquist theorem requires sampling above 40 kHz. The 44.1 kHz rate provides a small guard band above 40 kHz for the anti-aliasing filter to roll off, while keeping the data rate manageable. The specific number 44,100 was also chosen for compatibility with video equipment used during early digital recording.
Quick Check
Test your understanding of the key concepts from this lesson.






