I sample a 7 kHz tone 8000 times a second. What do the samples sound like? Watch the dots, then the wave through them.
Seven kilohertz, sampled at eight
Dots every 0.125 ms on a 7 kHz tone.
A 7 kHz tone, x_c(t): seven ups and downs every millisecond.
Describe this picture
One panel, 2 ms of a 7 kHz tone, with a key naming the traces as they appear: “7 kHz tone”, “samples x[n]” and “1 kHz wave through the same dots”. The first caption says “A 7 kHz tone, x_c(t): seven ups and downs every millisecond.” Seventeen dots, 0.125 ms apart on the tone, then drop onto it one after another, about every 0.2 s on screen, and the last has landed by 3.5 s: “8000 samples a second: one dot every 0.125 ms, seventeen dots in 2 ms.” The readout “dots taken” counts them from 0 to 17. Next the 7 kHz curve fades, a slower wave draws itself through the dots, and the caption says “The same dots fit a 1 kHz wave. With only the dots kept, the two cannot be told apart, and you hear 1 kHz.” The readout “slower wave through the dots” reads “not drawn yet” until the wave appears, then “1 kHz”. Two fixed readouts, “tone in” (7 kHz) and “sample rate f_s” (8 kHz), sit beside the “Hear the samples” button, which plays one second of the samples.
The same dots, two waves
First the words. The real tone, which goes on in continuous time, I will write . Sampling keeps its value every seconds, so the samples are
where is the sample number and is the sample rate, here 8000 samples a second, or 8 kHz. You met this in Sinusoids (3.2). The dots come every s, which is 0.125 ms.
Press “Hear the samples” in the picture at the top of the page: one second of the samples sounds at 1 kHz.
Look at the slow wave and find a dot it misses. There is none. It passes through all seventeen. It is a clean, smooth cosine, only the wrong one: the samples are exactly those of a 1 kHz cosine, so nothing in them says “7 kHz”. That is an alias: a clean, slower, wrong tone, not noise.
A ceiling fan filmed by a phone can seem to turn slowly, for the same reason. The camera sees the blades only once per frame.
Where a tone lands
Why 1 kHz and not some other number? The rule is the one from Sinusoids (3.2), written in hertz instead of radians per sample.
The digital frequency is (3.2 §4). Adding to adds to , and an extra gives the same samples (3.2 §5). So and give the same samples. A cosine is even, so and give the same samples too. Every tone therefore has a twin between 0 and half the sample rate. That half is the Nyquist frequency,
For the 7 kHz tone, 3.2’s rule goes like this: rad/sample. Subtract to get . Its mirror twin is , which is 1 kHz at 8 kHz.
Watch the dot as the input frequency climbs. Its landing point rises with it until the tone reaches kHz. Then it turns back down, reaching 0 at kHz, and climbs again.
Where a tone lands
Sample rate 8 kHz. Each input frequency lands somewhere from 0 to 4 kHz.
Sample rate 8 kHz. Watch where each input frequency lands.
Describe this picture
Sample rate 8 kHz. The input frequency, 0 to 24 kHz, runs along the bottom, and the height shows where it lands, from 0 to 4 kHz with a little headroom above, up to 4.8. Dotted guides mark f_N, f_s, 2f_s and 3f_s. The first caption says “Sample rate 8 kHz. Watch where each input frequency lands.” and both readouts, “tone in” and “lands at”, begin at 0.0 kHz. At 12 kHz the caption reads “Past f_N = 4 kHz the landing point turns back down; past f_s = 8 kHz it climbs again. 1, 7 and 9 kHz all land on 1 kHz.” and the readouts show 12.0 and 4.0 kHz. Rings are stamped along the path at 1, 7, 9, 15, 17 and 23 kHz, joined by a dashed line at 1 kHz, and the last caption says “Six different tones, one landing point: 1, 7, 9, 15, 17 and 23 kHz all sound like 1 kHz after sampling at 8 kHz.” When the clip has finished, dragging across the plot, or the arrow keys (0.5 kHz a step, Home and End for the ends), choose the input frequency, as the hint under the readouts says. The caption then follows, for example “7 kHz, sampled at 8 kHz, lands at 1 kHz.”
Notice the rings stamped along the path: six different tones, 1, 7, 9, 15, 17 and 23 kHz, all land on 1 kHz. When the animation has finished, the instrument is yours. Drag across the plot to choose the input frequency, pick 7 and check the dot sits at 1.
The rule behind the zig-zag has two steps. First take away whole sample rates: the remainder . For example , because . Then fold the remainder back below :
The fold is the cosine’s two arrows again. A cosine is two arrows spinning opposite ways (see Complex exponentials & phasors (3.4)). Sampling moves each arrow’s frequency up or down by whole multiples of . The arrow at moved up by sits at . The page The sampling theorem (10.2) draws the whole picture.
Now run it backwards. The dots trace a 1 kHz wave, and you know the tone was 7 kHz. The sample rate was between 5 and 10 kHz. What was it? Try : the tone lands at kHz. Try : and kHz. So the sample rate was 8 kHz or 6 kHz.
That is the catch. Once the dots are all you have, the tone and its alias cannot be told apart, and the aliasing cannot be undone. Converters filter before they sample, which is the subject of Anti-aliasing and practical converters (10.4).
The maths behind it · null spaces
Sampling keeps a few entries of a very long list. Two different lists that agree at the kept entries, the 7 kHz and the 1 kHz waves, become the same short list. Their difference is zero at every kept entry, so it is invisible. The set of differences that a map makes invisible is called its null space.
A square wave aliases at any note
So far there was one tone. Real sounds hold many. In Signals as sums of sinusoids (7.1) you built a square wave from spinning arrows at the odd harmonics , with lengths . They never stop.
That is the problem. However low the note, some harmonic lies above , and it lands somewhere else. Here is a 1.5 kHz square wave sampled at 8 kHz. Watch its first four harmonics move, one at a time, into the sampled panel.
A square wave's harmonics, folded
A 1.5 kHz square wave sampled at 8 kHz; its first four harmonics.
A 1.5 kHz square wave: lines at 1.5, 4.5, 7.5 and 10.5 kHz, the first four of its odd harmonics.
Describe this picture
Two panels, the input and the sampled spectrum, for a 1.5 kHz square wave sampled at 8 kHz. The first caption reads “A 1.5 kHz square wave: lines at 1.5, 4.5, 7.5 and 10.5 kHz, the first four of its odd harmonics.” The bars are labelled “k = 1”, “3”, “5” and “7”, with lengths 1.273, 0.424, 0.255 and 0.182, and a vertical line marks “f_N”. The bars then move one at a time into the sampled panel, each leaving a dashed outline where it was. After the second the caption says “1.5 kHz stays where it is. 4.5 kHz is above f_N = 4 kHz and lands at 3.5 kHz.” and the readout “last line moved” shows “4.5 → 3.5 kHz”. At the end it shows “10.5 → 2.5 kHz” and the caption says “After sampling: lines at 0.5, 1.5, 2.5 and 3.5 kHz. Only 1.5 kHz belongs to the note; the others are not multiples of it, so it sounds out of tune.” Fixed readouts “note” (1.5 kHz) and “sample rate f_s” (8 kHz) sit beside the “Hear the samples” button.
The first stays where it is; the other three land at 3.5, 0.5 and 2.5 kHz. Only 1.5 kHz belongs to the note, and the others are not multiples of it, so it sounds out of tune. Press “Hear the samples” to hear the sampled square wave. A cheap synthesiser whose high notes sound out of tune does exactly this.
The four lines shown carry 0.9496 of the square wave’s power (Fourier series coefficients (7.2)). The rest of the harmonics fold too. A caution: this works out of tune only when the note does not divide evenly. A 1 kHz square wave at 8 kHz folds its harmonics onto multiples of 1 kHz. At 1.5 kHz and 8 kHz, as here, they do not.
The maths behind it · sampled time series
A time series measured at a fixed interval aliases too. A daily temperature cycle read once every 25 hours shows a fake cycle: cycles per hour, so a cycle 600 hours, or 25 days, long.
Worked example
- A CD chain. A 25 kHz interferer meets kHz, so kHz. The remainder is kHz, less than , and above . So kHz, inside the audio band.
- 9 kHz at 10 kHz. kHz, and kHz.
- Through 3.2. 7 kHz at 8 kHz is rad/sample. Minus gives , whose twin is . That is 1 kHz.
- The 1.5 kHz square wave at 8 kHz. The harmonics at 1.5, 4.5, 7.5, 10.5, 13.5, 16.5, 19.5 and 22.5 kHz land at 1.5, 3.5, 0.5, 2.5, 2.5, 0.5, 3.5 and 1.5 kHz.
- Reverse. A 7 kHz tone that shows as 1 kHz, with kHz, means or kHz.
- Audio. To keep a 20 kHz tone below you need kHz. The page The sampling theorem (10.2) explains why that is enough.
Where you’ll meet this
Every audio interface, camera and sensor samples. The next pages build on this one. The page The sampling theorem (10.2) shows the copies of the spectrum behind the fold. The page Reconstruction (10.3) rebuilds the wave from its dots. The page Anti-aliasing and practical converters (10.4) filters first, so the alias never forms.
Reference card
| Quantity | Formula | Notes |
|---|---|---|
| Sampling | ||
| Nyquist frequency | half the sample rate | |
| Digital frequency | rad/sample | Sinusoids (3.2) |
| Twins | , and give the same samples | a whole number |
| Where a tone lands | , | |
| Square wave | harmonics never stop | some lie above for any note |