Skip to content
Tutorials Center
My learning

Topics

Lesson 27 of 36 ยท Sampling and Z-transform

The Sampling Theorem and the Nyquist Rate

Learn the Nyquist-Shannon sampling theorem, what the Nyquist rate means, how sampling repeats the spectrum, and rebuild a signal with sinc interpolation in Python.

Digital systems cannot store a continuous signal; they store its values at regular instants. The question that makes digital audio, video and measurement possible is: how fast must you sample so that nothing is lost? The answer is the sampling theorem, usually credited to Nyquist and Shannon.

Statement

If a continuous-time signal x(t) is bandlimited, meaning X(f) = 0 for |f| > B, and you sample it at a rate fs > 2B, then x(t) can be reconstructed exactly from its samples x[n] = x(n/fs). The minimum rate 2B is the Nyquist rate; half the sampling rate, fs/2, is the Nyquist frequency.

CD audio samples at 44,100 Hz, so it can capture content up to 22,050 Hz, just above the range of human hearing (about 20 kHz). Telephone speech uses 8,000 Hz and so keeps content below 4,000 Hz.

flowchart LR
    A["x(t) bandlimited to B"] --> B["Sample every Ts = 1/fs"]
    B --> C["x[n]"]
    C --> D["Ideal low-pass reconstruction"]
    D --> E["x(t) recovered if fs > 2B"]

The chain of ideal sampling and reconstruction.

What sampling does in the frequency domain

Sampling multiplies x(t) by an impulse train with spacing Ts = 1/fs. Multiplication in time is convolution in frequency, and an impulse train transforms into another impulse train at multiples of fs. The result is that the spectrum of the samples is the original spectrum repeated at every multiple of fs:

X_s(f) = fs ฮฃ over k of X(f - k fs).

If fs > 2B, the copies do not overlap, and an ideal low-pass filter with cutoff fs/2 isolates the original copy. If fs < 2B, the copies overlap and the information is mixed: this is aliasing, the subject of the next lesson.

Reconstruction with sinc interpolation

The ideal low-pass filter has a sinc impulse response, so perfect reconstruction is

x(t) = ฮฃ x[n] sinc((t - n Ts)/Ts).

Each sample contributes a sinc centered on its instant. It equals 1 at its own sample time and zero at all other sample times, so the reconstruction passes through every sample. The sum is infinite, so a finite record has small errors near its edges.

Python Sinc interpolation of a sampled sine

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.

Finding the Nyquist rate of a mixed signal

To choose a sampling rate you must know the highest frequency present. For a sum of sinusoids that is the largest frequency; for a general signal you estimate it from the spectrum. Take x(t) = sin(2ฯ€ยท30t) + 0.5 cos(2ฯ€ยท180t) + 0.2 sin(2ฯ€ยท75t). Its bandwidth is 180 Hz, so the Nyquist rate is 360 Hz. In practice you add a safety margin (oversampling) because real anti-alias filters are not ideal.

Python Estimating the bandwidth from an oversampled record

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.

Practical issues

  • Real signals are not exactly bandlimited. A signal limited in time cannot be limited in frequency, so engineers use an analog anti-aliasing filter before the sampler.
  • Real reconstruction is not an ideal sinc. DACs use a zero-order hold followed by an analog smoothing filter.
  • Oversampling (sampling well above 2B) relaxes the filter requirements and is used in audio converters.
  • Bandpass sampling allows a lower rate for signals that occupy only a band away from zero, as long as the band width is below fs/2 and the copies still do not overlap.

The theorem states a sufficient condition. Sampling at exactly 2B is a boundary case: a sine at exactly fs/2 can be sampled at its zero crossings and look like nothing. Always sample strictly above 2B.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. A signal contains frequencies up to 3 kHz. What is the minimum sampling rate that allows perfect reconstruction (ignoring margins)?

    The Nyquist rate is twice the highest frequency, 6 kHz. The sampling rate must be strictly greater than that.
  2. 2. What does sampling at rate fs do to the spectrum of a signal?

    Multiplying by an impulse train convolves the spectrum with an impulse train, producing copies centered at k fs.
  3. 3. Which impulse response corresponds to ideal reconstruction?

    The ideal low-pass filter has a rectangular frequency response, so its impulse response is a sinc.
  4. 4. Why do real systems oversample and use an anti-aliasing filter?

    Ideal brick-wall filters do not exist, so engineers sample above 2B and filter before sampling to keep the copies of the spectrum apart.

Summary

  • A bandlimited signal with maximum frequency B is fully determined by samples taken at fs > 2B.
  • Sampling repeats the spectrum every fs; non-overlapping copies mean no information loss.
  • Sinc interpolation is the ideal reconstruction; real systems approximate it.
  • Always plan for margins: anti-alias filters, oversampling and a guard band.

Next: Aliasing and Reconstruction