The Nyquist rate
About this lesson
How often must you sample a wave to keep it? Follow a 1000 Hz tone through a converter whose clock you slow down: at 8000 and 2500 samples a second the numbers rebuild the tone exactly, at exactly 2000 it vanishes, and at 1500 it comes back as a false 500 Hz tone. You will see why in the spectrum, learn the rule fs > 2·fmax, and meet the Nyquist rate and the Nyquist frequency. It follows the lesson "Sampling: taking snapshots"; the Circuits lesson on filters helps for the last step.
A 1 kHz tone
A tone generator makes a 1000 Hz tone: x(t) = sin(2π·1000·t) volts. It repeats 1000 times a second, so one cycle lasts 1 ms. The question: how often must we measure it to keep it?
x(t) = sin(2π·f·t) V f = 1000 Hz (cycles per second) T = 1/f = 1 ms per cycle peak = 1 V plot: 4 ms = 4 cycles sampling = measuring x(t) at evenly spaced instants (lesson "Sampling: taking snapshots") motion in the figure: slowed down a lot
Read the lesson step by step
A 1 kHz tone
A tone generator makes a 1000 Hz tone: x(t) = sin(2π·1000·t) volts. It repeats 1000 times a second, so one cycle lasts 1 ms. The question: how often must we measure it to keep it?
x(t) = sin(2π·f·t) V f = 1000 Hz (cycles per second) T = 1/f = 1 ms per cycle peak = 1 V plot: 4 ms = 4 cycles sampling = measuring x(t) at evenly spaced instants (lesson "Sampling: taking snapshots") motion in the figure: slowed down a lotA clock sets the sampling rate
A clock tells the converter (ADC) when to measure. At fs = 8000 samples a second it ticks every 125 µs: 8 samples in each 1 ms cycle. Each sample flies to memory as a number.
fs = 8000 samples per second Ts = 1/fs = 125 µs between samples per cycle: fs / f = 8000 / 1000 = 8 x[n] = x(n/fs) = sin(2π·1000·n/8000) x[0..4] = 0.00, 0.71, 1.00, 0.71, 0.00 VRebuild the wave from the numbers
Can the numbers alone give the wave back? A rebuilder (DAC) draws the smoothest wave through the dots: the one with no frequency above fs/2 = 4000 Hz. It lands exactly on the 1 kHz tone.
rebuild (ideal DAC): r(t) = Σ x[n]·sinc(fs·t − n) sinc(u) = sin(πu) / (πu) the only wave through the dots with no frequency above fs/2 fs/2 = 4000 Hz, tone = 1000 Hz -> kept r(t) = x(t): the two curves overlap how real DACs do it: lesson "DACs and reconstruction"Slower: 2.5 samples a cycle
Slow the clock to 2500 samples a second: only 2.5 samples per cycle. The dots look far too few, yet the smoothest wave through them is still exactly the 1 kHz tone.
fs = 2500 /s, Ts = 400 µs per cycle: 2500 / 1000 = 2.5 x[0..4] = 0.00, 0.59, −0.95, 0.95, −0.59 V fs/2 = 1250 Hz > 1000 Hz -> kept rebuilt wave = the 1000 Hz toneThe samples hold copies of the tone
A spectrum shows which frequencies a signal holds. The samples hold the 1 kHz tone plus copies at fs ± 1 kHz: 1.5 kHz, 3.5 kHz and more. The rebuilder keeps only 0 to fs/2 = 1.25 kHz.
samples taken fs times a second cannot tell f apart from k·fs ± f (k = 1, 2, ...) fs = 2500 Hz, f = 1000 Hz: tone 1.0 kHz copies 1.5, 3.5, 4.0, 6.0, 6.5, 8.5, 9.0 kHz ... rebuilder keeps 0 .. fs/2 = 1.25 kHz -> only the 1.0 kHz line: correctExactly 2 a cycle: the tone vanishes
At exactly 2000 a second, 2 samples per cycle, every tick here lands on a zero crossing. All samples read 0.00 and the rebuild is silence. The copy at fs − 1 kHz now sits on the tone and cancels it.
fs = 2000 /s = 2·f x[n] = sin(2π·1000·n/2000) = sin(π·n) = 0 x[0..4] = 0.00, 0.00, 0.00, 0.00, 0.00 V rebuilt: 0 V (silence) with another start time the dots land elsewhere: 2 per cycle cannot tell waves of different phase apartToo slow: a wrong, lower tone
At 1500 a second (1.5 per cycle) the copy at fs − 1 kHz = 500 Hz falls below fs/2 = 750 Hz. The rebuilder plays a 500 Hz tone, not 1 kHz. This false tone is an alias.
fs = 1500 /s, fs/2 = 750 Hz < 1000 Hz x[0..4] = 0.00, −0.87, 0.87, 0.00, −0.87 V copy: fs − f = 1500 − 1000 = 500 Hz rebuilt: −sin(2π·500·t), a 500 Hz tone the same dots fit both waves aliasing: next lessonThe Nyquist rate
The rule: sample faster than twice the highest frequency in the signal, fs > 2·fmax. That limit, 2·fmax, is the Nyquist rate: 2000 a second for our tone. Half the sampling rate, fs/2, is the Nyquist frequency.
sampling theorem (Shannon 1949): fs > 2·fmax -> samples keep everything Nyquist rate = 2·fmax (of the signal) Nyquist frequency = fs/2 (of the sampler) our tone: fmax = 1000 Hz Nyquist rate = 2000 /s 8000, 2500 ok 2000, 1500 fail strictly greater: = 2·fmax is not enoughReal systems keep a margin
Phone voice reaches about 3.4 kHz and is sampled 8000 times a second; its Nyquist rate is 6800. CDs cover hearing up to 20 kHz at 44,100 a second, above 40,000. The gap leaves room for a filter.
signal fmax Nyquist rate fs used phone voice 3.4 kHz 6800 /s 8000 /s CD audio 20 kHz 40,000 /s 44,100 /s the margin lets a real low-pass filter remove everything above fs/2 first (lesson "Anti-alias filters"; filters in Circuits, "Filters")Check it in Python
In Python with numpy, sample the tone at fs = 2000: n = np.arange(5), then x = np.sin(2*np.pi*f*n/fs). Every value is about 1e-16: zero plus floating-point rounding. The tone has vanished.
import numpy as np f, fs = 1000, 2000 n = np.arange(5) x = np.sin(2*np.pi*f*n/fs) >>> x.round(2) array([ 0., 0., -0., 0., -0.]) >>> np.abs(x).max() np.float64(4.898587196589413e-16) try fs = 2500: array([ 0. , 0.59, -0.95, 0.95, -0.59]) (Python 3 with numpy 2)
5 quick questions
Choose one answer per question. You can change your choices before checking them.
01A signal has no frequencies above 5 kHz. What is its Nyquist rate?
The Nyquist rate is twice the highest frequency: 2 × 5 kHz = 10,000 samples a second. To keep the signal you must sample faster than that.
02A converter samples 48,000 times a second. What is its Nyquist frequency?
The Nyquist frequency is half the sampling rate: 48,000 / 2 = 24 kHz. Frequencies above it cannot be told apart from lower ones.
03A 1000 Hz tone is sampled 1500 times a second and rebuilt. Which tone comes out?
fs/2 = 750 Hz is below 1000 Hz, so the copy at fs − f = 1500 − 1000 = 500 Hz is the one inside 0 .. fs/2. The rebuilder plays that alias.
04Why does the theorem need fs strictly greater than 2·fmax, not equal to it?
At fs = 2f, a sine sampled at its zero crossings gives 0, 0, 0 ... and a cosine gives +1, −1, +1 ... Waves of different phase give the same samples, so the tone cannot be pinned down.
05CD audio aims to keep sounds up to 20 kHz. Why 44,100 samples a second and not exactly 40,000?
Real low-pass filters cannot cut off instantly. The gap between 20 kHz and fs/2 = 22.05 kHz gives the anti-alias filter room to work.
Glossary
- Sampling rate (fs)
- How many samples are taken each second; the time between samples is Ts = 1/fs.
- Nyquist rate
- Twice the highest frequency in a signal, 2·fmax. Sampling faster than it keeps the signal.
- Nyquist frequency
- Half the sampling rate, fs/2: the highest frequency a sampler can represent without confusion.
- Sampling theorem
- A signal with no frequencies above fmax is completely set by samples taken at fs > 2·fmax (Shannon, 1949).
- Reconstruction
- Rebuilding the continuous wave from its samples; the ideal rebuilder draws the wave through them with no frequency above fs/2 (sinc interpolation).
- Spectrum
- A picture of which frequencies a signal holds and how strong each one is.
- Alias
- A false, lower frequency that a too-slow sampler makes out of a higher one, here 500 Hz from 1000 Hz.
Notes and sources
- The 1000 Hz, 1 V tone and the four clock rates are chosen examples. Every value, dot and curve in the figure is computed from the model: the rebuilt wave by Whittaker–Shannon (sinc) interpolation of 8001 samples, the spectrum as the DTFT of 40 ms of Hann-windowed samples.
- The motion is slowed down a great deal: the real clock ticks thousands of times a second.
- At exactly fs = 2f the result depends on where the samples fall: a sine sampled at its zero crossings gives all zeros, a cosine gives +1, −1, +1 ... That ambiguity is why the theorem needs fs strictly greater than 2f.
- Telephone (ITU-T G.711) samples 8000 times a second for a voice band of about 300 to 3400 Hz; CD audio samples 44,100 times a second for hearing up to about 20 kHz, leaving a 2.05 kHz band for the anti-alias filter.
- A. V. Oppenheim, A. S. Willsky, S. H. Nawab, Signals and Systems, 2nd ed., Pearson (ch. 7: Sampling, the sampling theorem, reconstruction, aliasing)
- A. V. Oppenheim, R. W. Schafer, J. R. Buck, Discrete-Time Signal Processing (course text listed on MIT OCW 6.341 readings)
- B. P. Lathi, R. A. Green, Linear Systems and Signals, Oxford University Press, 2018, chapter "Sampling: the bridge from continuous to discrete" (Internet Archive record)
- MIT OpenCourseWare 6.003 Signals and Systems (D. Freeman, Fall 2011)
- MIT OpenCourseWare RES.6-007 Signals and Systems (A. V. Oppenheim): modulation and sampling
- MIT OpenCourseWare 6.341 Discrete-Time Signal Processing (A. V. Oppenheim)
- Nyquist–Shannon sampling theorem (Wikipedia): fs > 2B, the critical case at fs = 2B, sinc reconstruction, Shannon 1949
- Nyquist rate (Wikipedia): twice the highest frequency; Nyquist frequency is half the sample rate
- 44,100 Hz (Wikipedia): why CD audio uses 44.1 kHz
- Voice frequency (Wikipedia): telephone band about 300 to 3400 Hz, sampled at 8 kHz
- G.711 (Wikipedia): telephone audio sampled 8000 times a second
- NumPy documentation: numpy.sin (angles in radians)
- NumPy documentation: numpy.arange
Quiz Unlocks after the last step.