Sampling Theorem and Aliasing: Nyquist Rate with Worked Examples

Every digital communication system and every microcontroller ADC begins by sampling: measuring a continuous signal at regular instants and keeping only those numbers. The sampling theorem tells you how fast you must sample so that nothing is lost. Break it, and a high-frequency signal quietly turns into a false low-frequency one called an alias, which no amount of software can remove afterwards.

This tutorial states the theorem, explains why aliasing happens in the frequency domain, gives a formula to predict alias frequencies, and walks through practical sample-rate and filter choices.

The Theorem

A signal that contains no frequency components above fmax can be perfectly reconstructed from samples taken at a rate fs, provided:

fs > 2 x fmax

Nyquist rate      = 2 x fmax          (minimum sampling rate)
Nyquist frequency = fs / 2            (highest frequency a given fs can represent)
Sampling interval Ts = 1 / fs

Strictly, the inequality must be greater-than. Sampling a sine wave at exactly twice its frequency can land every sample on the zero crossings and record nothing at all. In practice engineers sample 2.2 to 10 times faster than fmax so that a real filter can do the job of rejecting higher frequencies.

ApplicationSignal bandwidthSample rate used
Telephone voice (PCM)300 Hz to 3.4 kHz8 kHz
Audio CD20 Hz to 20 kHz44.1 kHz
Professional audio / video20 kHz48 kHz
Vibration monitoring exampleup to 1 kHz5 kHz or more

Why Aliasing Happens

Mathematically, sampling multiplies the signal by a train of impulses spaced Ts apart. In the frequency domain this creates copies of the original spectrum centred at 0, fs, 2fs, 3fs and so on. If the original spectrum extends beyond fs/2, neighbouring copies overlap. A receiver or reconstruction filter cannot tell which copy a component came from, so high frequencies fold back into the band from 0 to fs/2.

Spectrum after sampling (signal bandwidth B):

  |  [orig]        [copy]        [copy]
  |---B---|.......|--fs--|......|--2fs--|....
  0       B   fs-B  fs  fs+B  2fs-B 2fs

No overlap if  B < fs - B,  i.e.  fs > 2B

You have seen aliasing in films where a car's wheel appears to spin slowly backwards. The camera samples at 24 or 25 frames per second, and the wheel's spoke pattern moves faster than half of that.

Predicting the Alias Frequency

For an input tone at frequency f sampled at fs, the apparent frequency after sampling is the distance from f to the nearest integer multiple of fs:

f_alias = | f - k x fs |,  where k is the integer that makes the result <= fs/2

Worked Example 1

fs = 1000 Hz, input f = 700 Hz  (above fs/2 = 500 Hz)
k = 1:  f_alias = |700 - 1000| = 300 Hz
The ADC output looks exactly like a 300 Hz sine.

Worked Example 2

fs = 1000 Hz, input f = 2350 Hz
Nearest multiple: 2 x 1000 = 2000
f_alias = |2350 - 2000| = 350 Hz

Worked Example 3: Mains Hum in a Slow Logger

A data logger samples a sensor at 45 samples per second. The sensor wiring picks up 50 Hz mains hum.

f_alias = |50 - 1 x 45| = 5 Hz
The log shows a slow 5 Hz wobble that is not in the real process.

This is a classic beginner bug. Either filter the 50 Hz out in hardware before the ADC, or sample synchronously, for example at an exact integer number of samples per mains cycle and average over whole cycles.

Choosing an Anti-Aliasing Filter

Because aliases cannot be removed after sampling, a low-pass filter must sit before the ADC. Its job is to attenuate everything above fs/2 to below the ADC's resolution, while passing the wanted band.

First-order RC low-pass:  fc = 1 / (2 pi R C)
Roll-off: 20 dB per decade per order

Example: wanted band 0-1 kHz, choose fc = 1.6 kHz
R = 10 k, C = 10 nF -> fc = 1 / (2 pi x 10e3 x 10e-9) = 1.59 kHz

To be 40 dB down with a 1st-order filter you need 2 decades
above fc (159 kHz). So fs must be far above 2 kHz,
or the filter must be higher order.
Filter orderRoll-offFrequency where 40 dB reached (fc = 1.6 kHz)
1st (single RC)20 dB/decadeabout 160 kHz
2nd (Sallen-Key)40 dB/decadeabout 16 kHz
4th80 dB/decadeabout 5 kHz

This shows the trade-off: a simple filter needs heavy oversampling, while a sharper filter allows a sample rate closer to the Nyquist rate. Modern sigma-delta audio ADCs oversample internally by large factors so that a gentle analog filter is enough.

Bandpass Sampling (Undersampling)

The rule fs > 2 fmax applies to baseband signals. If the signal occupies only a narrow band, for example 10.6 to 10.8 MHz, you can sample below twice the highest frequency and deliberately use aliasing to shift the band down, as long as the copies do not overlap. The requirement then becomes fs > 2B, where B is the signal bandwidth, plus conditions on where the band sits relative to multiples of fs/2. Software-defined radios use this technique, but a band-pass filter is essential to stop other bands folding in.

Common Mistakes

  • Sampling at exactly 2 fmax and expecting to capture a sine wave.
  • Relying on a digital filter after the ADC to remove aliases. By then they are indistinguishable from real signals.
  • Forgetting harmonics. A 1 kHz square wave has components at 3, 5, 7 kHz and beyond, all of which can alias.
  • Ignoring interference such as 50 Hz hum or switching regulator noise that lies above fs/2.

Summary

Sample faster than twice the highest frequency present, not just the highest frequency you care about. Anything above fs/2 folds back to |f - k fs| and looks real. Put an analog low-pass filter before the ADC and choose fs high enough that the filter has room to roll off. With sampling understood, the next step is quantization, where each sample is rounded to a fixed number of bits.