Textbooks/Signals and Systems/Chapter 2Lite (plain text) version
2Sampling and the Nyquist rate
Version 1 · Technically checked (automated checks only) · 4 source lessons · 7 practice items
Introduction
A computer cannot store a smooth curve; it stores a list of numbers taken at regular instants. How often is often enough? Sample a sinusoid more than twice per cycle and its frequency can be recovered; sample less and the information is gone. That threshold, twice the highest frequency present, is the Nyquist rate. Engineers sample well above it, because real filters and real signals are never perfect.
Explanation
This chapter is built from 4 School lessons. Each part below is the lesson's own explanation; open the lesson for its predict-and-discover activities.
2.1 Sampling: how often is often enough?
In films, a fast car's wheels sometimes seem to spin backwards. What has that got to do with a temperature sensor?
Rate and period
The sample rate fs is samples per second (Hz); the sample period is the time between samples, 1 ÷ fs. A greenhouse logger sampling at 0.1 Hz takes one reading every 10 s; an audio recorder at 44,100 Hz takes one every 22.7 µs. Samples recorded = rate × duration: 50 Hz for 60 s gives 3,000 samples.
Samples per cycle
Divide the sample rate by the signal frequency to get samples per cycle. Ten or more show the wave's shape clearly. Between two and about five catch the frequency but the shape looks rough. Fewer than two per cycle cannot represent the wave at all. So a signal with frequency f needs a sample rate of more than 2f: half the sample rate is the highest frequency you can capture.
Aliasing and how to avoid it
When a signal is too fast for the sample rate, its samples line up into a slower, false wave: an alias. A 9 Hz wiggle sampled at 10 Hz pretends to be 1 Hz, and no maths afterwards can tell the difference. Engineers prevent it by sampling fast enough for every frequency present and by filtering out faster wiggles (like mains hum) before the ADC.
Common mix-ups
- Sampling too slowly just makes the wave a bit rough.
✓ Below two samples per cycle the samples show a different, false frequency. That is worse than roughness: it is wrong information. - You can fix aliasing later with clever software.
✓ Once aliased, the false wave looks exactly like a real slow one. Prevent it with a fast enough rate and a filter before sampling.
Open the full lesson: Sampling: how often is often enough? →
2.2 Sampling and the Nyquist rate
A computer can't watch a signal continuously; it takes snapshots. How many snapshots a second are enough to catch a 50 Hz hum?
Samples, not signals
A sampler measures the signal every Tₛ = 1/fₛ seconds, where fₛ is the sample rate in hertz. Between samples the computer knows nothing. Any two signals that agree at every sample instant are indistinguishable afterwards, however different they were in between.
The Nyquist rate
To capture a sine wave of frequency f, you need more than two samples per cycle: fₛ > 2f. For a signal whose highest frequency is f_max, the Nyquist rate is 2·f_max. Equivalently, a given fₛ can faithfully represent frequencies only up to fₛ/2, called the Nyquist frequency.
Margins in practice
Exactly 2f is a knife edge: sampled at the wrong phase, a wave right at the limit can vanish. Engineers sample with a comfortable margin, often 5–10 times the highest frequency of interest for control and monitoring, and use an analogue filter to remove anything above fₛ/2 before sampling.
Common mix-ups
- Sampling at exactly twice the frequency is enough.
✓ You need more than twice; at exactly 2f a wave can vanish if sampled at its zero crossings. - Sampling faster always gives better data.
✓ Above a comfortable margin it mostly adds cost, and noise above the band of interest still needs filtering.
2.3 From a wave to a list of numbers
Your phone's microphone hears a smooth, endless pressure wave. Your phone stores a list of whole numbers. What happened in between?
Two independent choices: time and value
A continuous-time signal x(t) has a value at every instant. A discrete-time signal x[n] exists only at the sample instants. Separately, a value can be analog (any real number) or quantised (one of a fixed set of levels). A digital signal is both discrete in time and quantised in value. The two steps are done by one chip, an ADC, but they cause different errors: sampling can cause aliasing, quantising adds rounding noise.
x[n] = x(nT)
Uniform sampling takes one value every T seconds; the sample rate is fs = 1/T. Sample n is the value at t = nT. The list x[0], x[1], x[2], … is all a processor ever sees. Square brackets mean an integer index; round brackets mean real time. Mixing them up is the commonest source of off-by-a-factor bugs in signal code.
Energy and power
For a sequence, energy E = Σ x[n]², the sum of squared samples (for a voltage across 1 Ω this is proportional to the energy delivered). Signals that go on for ever, like a sine wave, have infinite energy, so we use average power P = mean of x². A sinusoid of amplitude A has P = A²/2, and its RMS value √P = A/√2 is the steady voltage that would deliver the same power.
Common mix-ups
- Digital just means sampled.
✓ Digital means sampled in time and quantised in value: two separate steps with two separate kinds of error. - The sample index n is the time.
✓ n counts samples. Time is n·T = n/fs, so the same n means a different instant at a different sample rate.
2.4 How fast is fast enough?
Film a spinning wheel and it can appear to turn slowly backwards. Is the camera lying, or are you?
The sampling theorem
If a signal contains no frequencies at or above B, sampling at fs > 2B keeps all its information: the original can be rebuilt exactly from the samples (by ideal interpolation). fs/2 is called the Nyquist frequency; 2B is the Nyquist rate. Below that, information is lost and, worse, disguised.
Why twice?
To capture a sinusoid you need at least a high sample and a low sample in every cycle, more than two per period. At exactly two samples per cycle you might hit only the zero crossings and see nothing at all. That is why the inequality is strict.
Real systems add margin
CD audio samples at 44.1 kHz to cover hearing up to about 20 kHz: Nyquist is 22.05 kHz, leaving room for an anti-aliasing filter to roll off. Control loops often sample 10–20 times faster than the dynamics they control, because they need the signal's shape, not just its frequency.
Common mix-ups
- Sampling at exactly twice the highest frequency is enough.
✓ You need strictly more than twice; at exactly 2B you can land on zero crossings and lose the signal. - Frequencies above Nyquist are simply missed.
✓ They are not missed: they reappear at a false lower frequency (an alias).
Worked examples
Sampling: how often is often enough?: example 1
You want to measure 50 Hz mains hum on a sensor line. What is the slowest sample rate that could possibly capture it, and what would you actually choose?
Solution
More than 2 × 50 = 100 Hz is the bare minimum. To see the shape you might choose 1,000 Hz: 20 samples per cycle.
Sampling: how often is often enough?: example 2
A logger samples at 250 Hz for 30 s. How many samples?
Solution
250 × 30 = 7,500 samples.
Sampling and the Nyquist rate: example 1
A wheel encoder produces pulses at up to 300 Hz. What is the Nyquist rate, and what would you choose?
Solution
Nyquist rate = 2 × 300 = 600 Hz. A sensible choice is around 3–6 kHz so each pulse is seen several times and timing is precise.
From a wave to a list of numbers: example 1
x(t) = 3·cos(2π·2·t) is sampled at fs = 8 Hz. List x[0] to x[3].
Solution
f/fs = 1/4, so each sample advances the phase by 90°. x[0] = 3cos 0 = 3, x[1] = 3cos 90° = 0, x[2] = 3cos 180° = −3, x[3] = 3cos 270° = 0.
From a wave to a list of numbers: example 2
What is the energy of x = [1, 2, −1, 0]?
Solution
E = 1² + 2² + (−1)² + 0² = 6. Squaring makes negative samples count just as much as positive ones.
How fast is fast enough?: example 1
An accelerometer measures vibrations up to 400 Hz. Which of 500 Hz, 1 kHz or 2 kHz would you choose?
Solution
500 Hz fails (Nyquist 250 Hz). 1 kHz just works in theory (Nyquist 500 Hz) but leaves little room for a filter. 2 kHz gives a comfortable margin: choose it, unless storage or power rules it out.
Interactive figures
Interactive figure (online). Description: In the signal lab, a 9 Hz wave sampled 10 times a second gives dots that trace a slow 1 Hz wave: the readout warns that there are fewer than 2 samples per cycle. Raising the sample rate above 18 Hz removes the warning, and around 40–60 Hz the dots clearly follow the real wave's shape.
Interactive figure (online). Description: In the sampler at fs = 20 Hz, the samples follow the signal faithfully until f reaches 10 Hz (the Nyquist frequency). Above that, the dots trace a slower false wave: at 12 Hz they look like 8 Hz. At exactly 20 Hz every sample has the same value, so the alias is 0 Hz.
Laboratory
Everything runs in your browser. No kit, nothing mains-powered. Simulations are simplified educational models.
Studio
Code Lab
Sample a 10 Hz sine at 15, 25 and 50 Hz and plot each set of samples against the original.
Open Code Lab →Simulation OS experiment
Simulation OS: Battery sensor node
Halve the sample rate and see how much battery it saves; decide whether the signal survives.
Open Simulation OS: Battery sensor node →
Guided practice
Answers are checked on the server; wrong answers get a hint and another try. Signed in, solved items also count towards the source lesson.
- A signal is sampled at fs = 1 kHz from t = 0. At what time, in seconds, is sample x[250] taken? (s)
- You sample a 1 Hz signal at 10 Hz. How many samples land in each cycle of the signal? (samples)
- A sensor is sampled at 200 Hz. How long is the gap between samples, in milliseconds? (ms)
- A data logger samples at 250 Hz. What is the highest frequency it can represent unambiguously (the Nyquist frequency), in Hz? (Hz)
- A 40 Hz vibration is sampled at 1 kHz. How many samples fall in each cycle?
- A signal's highest frequency is 300 Hz. Which sample rate is the smallest of these that works?
- 300 Hz
- 600 Hz
- 601 Hz
- 450 Hz
- A control loop's fastest dynamics are at 8 Hz and the rule of thumb is to sample 20 times faster. What sample rate, in Hz? (Hz)
Engineering applications
Audio
Human hearing tops out around 20 kHz, so CD audio samples at 44.1 kHz: a little over twice the highest frequency, with room for the filter that removes anything above it.
Battery versus bandwidth
Every sample costs energy and storage. A sensor node samples only as fast as its fastest interesting signal requires, with a margin, rather than as fast as it can.
Watch
Optional verified videos. Nothing loads from YouTube until you press play.
- Shannon Nyquist Sampling Theorem (Steve Brunton)
- The intuition behind the Nyquist-Shannon Sampling Theorem (Zach Star)
Chapter summary
- Sampling stores a signal's value every Ts seconds; the sample rate is fs = 1 / Ts.
- The Nyquist rate is twice the highest frequency in the signal.
- A sampler at fs can represent frequencies up to fs / 2, the Nyquist frequency.
- Practical systems sample comfortably above the Nyquist rate.
Glossary
- Sampling and aliasing
- Sampling measures a signal at regular intervals. Any frequency above half the sample rate, the Nyquist frequency, is indistinguishable from a lower 'alias' frequency.
- Frequency and period
- Frequency is how many cycles happen per second; the period is the time for one cycle. Each is the reciprocal of the other.
- ADC resolution
- An n-bit analogue-to-digital converter splits its reference voltage into 2^n steps; one step, the least significant bit, is the smallest change it can detect.
Definitions from the Field Guide.
Project: Choose a sample rate
Pick three signals a robot might measure, such as wheel speed, motor current and a microphone. Estimate the highest frequency each contains, choose a sample rate with a stated margin, and calculate the data rate each produces in bytes per second.
Deliverables
- A table of signals, highest frequencies and chosen rates
- The margin you chose and why
- The data rate for each signal
Keep your work in your Engineering Journal; it stays private unless you choose to share it.
References
- Harry Nyquist (1928). "Certain Topics in Telegraph Transmission Theory". Transactions of the American Institute of Electrical Engineers 47(2), 617–644.
- Claude E. Shannon (1949). "Communication in the Presence of Noise". Proceedings of the IRE 37(1), 10–21.
- Alan V. Oppenheim and Ronald W. Schafer (2010). Discrete-Time Signal Processing, 3rd edition. Pearson.
Publication record
- Version
- 1
- Status
- Technically checked (automated checks only)
- Technical review
- Automated checks only, last run 2026-11-29. No human, educator or mentor review is claimed.src/content/textbooks/textbooks.test.ts: schema, every lesson, diagram, practice item, video, Field Guide entry, lab and reference resolves; figure numbers recomputed; no practice answers in client payloads.
- Written by
- Compiled and written by the Tactiverge team with AI assistance, from Tactiverge School lessons that were themselves written with AI assistance.
- Licence
- All rights reserved by the founders unless a licence is approved.
- Corrections
- None recorded yet.Spotted a mistake? Use “Report a problem” on any chapter, or see the corrections page.