A wheel and a camera
A wheel turns once a second: 1 turn per second is a frequency of 1 hertz (Hz). Watch one red spot. Its height above the axle rises and falls as a sine wave, x(t) = sin(2π·f·t). That is our signal.
A camera takes 8 frames a second, one every Ts = 1/8 s = 125 ms. Each frame records the spot's height at that instant: a sample, x[n] = x(n·Ts). Between frames the camera sees nothing.
At 1 turn a second the spot moves 360°/8 = 45° between frames. Played back on a screen, the wheel turns forward once a second, as it really does. 1 Hz is below fs/2 = 4 Hz, the Nyquist limit.
Too fast for the camera
Now the wheel turns 7 times a second. The camera still takes only 8 frames a second, so between two frames the wheel turns 7/8 of a turn: 315°. Almost all of the motion happens unseen.
315° forward ends exactly where 45° backward would. Your eye links each frame to the next by the shortest turn, so on the screen the spot steps back 45° a frame: the wheel seems to turn backward once a second. This is the wagon-wheel effect.
For every whole number n, sin(2π·7·n/8) = −sin(2π·n/8). So the 7 Hz wave and a slow −1 Hz wave pass through exactly the same samples. From the numbers alone nobody can tell them apart. The false, slower wave is called an alias.
The folding rule
Spin the wheel 8 times a second, the same as the frame rate. It makes exactly one whole turn between frames, so every frame finds the spot in the same place. On the screen the wheel stands still: the alias is 0 Hz.
The seen frequency is f − k·fs, where k is the whole number that brings it between −4 and +4 Hz. So 1 → 1, 7 → −1, 8 → 0, 9 → +1. Anything above fs/2 = 4 Hz folds back into that band.
In code and in practice
With numpy, sample both waves at the same 8 instants n/8 s. np.sin takes radians. np.allclose compares the two arrays and prints True: the 7 Hz samples and the −1 Hz samples are the same list of numbers.
Sample faster than twice the highest frequency: fs > 2·f. A 7 Hz spin needs more than 14 frames a second. If you cannot, remove frequencies above fs/2 before sampling with a low-pass anti-alias filter: the next lesson.
The working
# step 1/10 · wheel
wheel f = 1 turn per second = 1 Hz
signal x(t) = sin(2π·f·t)
height of the red spot above the axle,
in wheel radii (−1 .. +1)
t = 0 spot at "3 o'clock", height 0
t = 0.25 s spot at the top, height 1
motion in the figure: 12 times slower than real
The frame rate of 8 frames a second and the speeds of 1, 7 and 8 turns a second are chosen so the numbers stay small; the same rule holds for any rate (Oppenheim & Willsky, ch. 7). Every curve and value in the figure is computed from this model. The wheel turns 12 times slower than the speeds in the text, so you can follow it. The screen glides each new frame by the shortest turn, which is how the eye links the frames of a film.