Skip to content
Tutorials Center
My learning

Topics

Lesson 17 of 46 ยท Sampling and Digital Transmission

The sampling theorem and aliasing

Learn why sampling at twice the bandwidth is enough, how spectral replicas cause aliasing, how to choose an anti-aliasing filter and reconstruct with sinc.

How often must you measure a signal to be able to rebuild it exactly? Too slow and the measurements are ambiguous; too fast and you waste storage. The sampling theorem answers with a surprising precision: a signal containing no frequencies above B is completely determined by samples taken at any rate above 2B. The result sits under every digital audio, video and measurement system.

Top: a sine sampled eight times per cycle and 1.25 times per cycle with a slower alias. Bottom: spectra with replicas that stay apart or overlap
Fast sampling keeps spectral copies apart; slow sampling makes them overlap.

What you will learn

  • What the spectrum of a sampled signal looks like.
  • The statement of the sampling theorem and the Nyquist rate.
  • How aliasing arises and how to compute alias frequencies.
  • Why every sampler needs an anti-aliasing filter.

Key terms

  • Sampling frequency fs = 1/Ts: samples per second.
  • Nyquist rate: 2B, the minimum sampling rate for a signal of bandwidth B.
  • Aliasing: a frequency above fs/2 showing up at a false lower frequency.
  • Anti-aliasing filter: a low-pass filter before the sampler.
  • Reconstruction filter: the low-pass filter after the converter that restores the continuous signal.

What sampling does to the spectrum

Sampling multiplies x(t) by a train of impulses spaced Ts apart. In the frequency domain, multiplication by a periodic impulse train produces a periodic repetition:

Xs(f) = fs ยท ฮฃ X(f โˆ’ k ยท fs), for all integers k.

The spectrum of the sampled signal is the original spectrum repeated at every multiple of the sampling frequency. If X(f) is limited to |f| โ‰ค B, the copies are separated as long as fs โˆ’ B > B, i.e. fs > 2B. Then a low-pass filter with cutoff between B and fs โˆ’ B removes all copies except the original, and the original signal is recovered exactly. That is the sampling theorem (Nyquist, 1928; Kotelnikov, 1933; Shannon, 1949; Whittaker's earlier mathematical version, 1915).

Ideal reconstruction in the time domain is sinc interpolation:

x(t) = ฮฃ x(n Ts) ยท sinc( (t โˆ’ n Ts) / Ts ).

Each sample contributes a sinc pulse that is 1 at its own instant and 0 at all other sampling instants.

Aliasing

If fs โ‰ค 2B the copies overlap and cannot be separated: high-frequency content folds down onto low frequencies. A sinusoid at frequency f sampled at fs produces exactly the same samples as one at f โˆ’ k fs for any integer k. The apparent (alias) frequency is the distance from f to the nearest multiple of fs:

f_alias = | f โˆ’ round(f / fs) ยท fs |.

Worked examples:

  • A 7 kHz tone sampled at 10 kHz: nearest multiple is 10 kHz, so the alias is |7 โˆ’ 10| = 3 kHz.
  • A 5 kHz tone sampled at 8 kHz: the nearest multiple is 8 kHz, alias 3 kHz.
  • A 1.1 kHz tone sampled at 1 kHz: alias 0.1 kHz; this is the familiar "wagon wheel" effect in film, where a wheel spinning slightly faster than the frame rate appears to turn slowly forward or backward.

Once aliasing has happened it cannot be undone: the samples are identical to those of the low-frequency tone.

Anti-aliasing and practical rates

Real signals always contain some energy above the nominal band, as do noise and interference. Therefore a sampler is always preceded by an anti-aliasing filter that removes everything above fs/2. Real filters are not brick walls, so systems sample a little above the Nyquist rate to leave a transition band:

  • Telephony: speech limited to about 3.4 kHz and sampled at 8 kHz, leaving a guard band from 3.4 to 4.6 kHz (8 โˆ’ 3.4).
  • Audio CD: content to 20 kHz, fs = 44.1 kHz, so the transition band lies between 20 and 24.1 kHz (44.1 โˆ’ 20).

A cheaper trick is oversampling: sample at a high rate with a gentle analog filter, then filter and decimate digitally.

Common misconceptions

"Sampling at exactly 2B is fine." At exactly 2B a component at B may be lost (a sine sampled exactly at its zero crossings gives zeros). Use strictly more than 2B.

"Samples are a rough approximation of the signal." If the signal is band-limited and sampled fast enough, the samples determine the signal exactly.

"I can remove aliases afterwards." After sampling, an alias is indistinguishable from a real low-frequency component. Filter before sampling.

Try it

The first example demonstrates aliasing numerically: a 5 kHz tone and a 3 kHz tone sampled at 8 kHz give identical samples up to a sign. The plot shows both curves passing through the same points.

Python Two tones, one set of samples

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The second example reconstructs a band-limited signal from samples with sinc interpolation. The signal has components at 1 and 3 Hz (bandwidth 3 Hz) and is sampled at 8 Hz, above the Nyquist rate of 6 Hz. The error is small away from the edges of the sampled window.

Python Sinc reconstruction

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. A signal has no content above 12 kHz. The minimum sampling rate for exact recovery is

    fs must exceed 2B = 24 kHz.
  2. 2. A 9 kHz tone is sampled at 12 kHz. It will appear at

    The nearest multiple of 12 kHz is 12 kHz, and |9 โˆ’ 12| = 3 kHz.
  3. 3. What does the spectrum of a sampled signal look like?

    Xs(f) = fs ฮฃ X(f โˆ’ k fs).
  4. 4. Why must an anti-aliasing filter come before the sampler?

    The aliased samples are identical to those of a real low-frequency tone.
  5. 5. Which interpolation function perfectly reconstructs a band-limited signal?

    Sinc interpolation is the ideal low-pass reconstruction; the others only approximate it.

Summary

  • Sampling repeats the spectrum at multiples of fs; fs > 2B keeps the copies apart.
  • Alias frequency: |f โˆ’ round(f/fs) fs|; it cannot be removed after sampling.
  • Always filter before sampling; practical rates include a guard band.
  • Ideal reconstruction is sinc interpolation.

Next: Quantization and PCM