Sample a 60-hertz sine wave 100 times a second and the numbers that come out are, to thirteen decimal places, the same numbers a 40-hertz sine wave would produce. Not similar. The same. Once the samples are taken, nothing in the data can tell the two apart, and a frequency analysis reports a clean peak at 40 Hz. That is aliasing, and it’s the reason every sensor logger, audio interface and oscilloscope has to deal with the Nyquist limit. A few lines of NumPy show it happening, and a little arithmetic predicts exactly where any frequency will land.
The rule
Twice the highest frequency
Analog Devices’ tutorial What the Nyquist Criterion Means to Your Sampled Data System Design (MT-002, by Walt Kester) states the criterion this way: the sampling frequency must be at least twice the highest frequency contained in the signal. Half the sampling rate is the Nyquist frequency, and the band from zero up to it is the first Nyquist zone.
What happens above the limit
The same tutorial says that sampling below the Nyquist rate causes aliasing, and that content outside the band will be aliased back into the first Nyquist zone. It describes the frequency spectrum as divided into an infinite number of Nyquist zones, each half the sampling rate wide. A frequency in any zone folds back into the first one like a strip of paper folded accordion-style.

Proving it with NumPy
The test
import numpy as np
fs = 100
t = np.arange(0, 2, 1/fs)
x = np.sin(2*np.pi*60*t) # 60 Hz, sampled at 100 Hz
y = -np.sin(2*np.pi*40*t) # 40 Hz, inverted
print(np.max(np.abs(x - y))) # 1.69e-13
X = np.abs(np.fft.rfft(x))
f = np.fft.rfftfreq(len(x), 1/fs)
print(f[np.argmax(X)]) # 40.0What it shows
The largest difference between the two sets of samples was 1.69 × 10⁻¹³, floating-point rounding and nothing else. The frequency analysis found its peak at 40.0 Hz. A sensor sampling at 100 Hz near a power cord carrying 60 Hz mains would log a 40 Hz signal that doesn’t exist in the room.
Predicting where a frequency lands
The folding formula
Reduce the frequency modulo the sampling rate, then reflect anything above half the sampling rate back down:
def alias(f, fs):
f = f % fs
return min(f, fs - f)Worked examples
| Signal | Sampling rate | Appears as |
|---|---|---|
| 60 Hz | 100 Hz | 40 Hz |
| 60 Hz | 50 Hz | 10 Hz |
| 50 Hz | 60 Hz | 10 Hz |
| 900 Hz | 1,000 Hz | 100 Hz |
| 1,100 Hz | 1,000 Hz | 100 Hz |
| 440 Hz | 500 Hz | 60 Hz |
| 25,000 Hz | 44,100 Hz | 19,100 Hz |
| 28,000 Hz | 44,100 Hz | 16,100 Hz |
Signals at 900 Hz and 1,100 Hz both fold to 100 Hz at a 1 kHz sampling rate, so after sampling they’re indistinguishable from each other and from a real 100 Hz tone. The last two rows are why audio recorders filter out ultrasonic content before sampling at 44.1 kHz: a 25 kHz tone nobody can hear would come back as a 19.1 kHz tone that some people can.

Aliasing in everyday sensor projects
Mains hum in a slow logger
A temperature logger reading once every 20 milliseconds, 50 times a second, sees 60 Hz electrical interference as a 10 Hz wobble. In the test, averaging ten seconds of that aliased interference gave a mean of essentially zero, so a long average hides it. A short average, or a reading taken once a minute, catches the wobble at a random point in its cycle and turns it into noise that never averages away within the reading. Sampling at exactly a multiple of the mains frequency, or averaging over a whole number of mains cycles, removes it instead.
Spinning things on video
Cameras sample too. A fan turning at 1,450 revolutions per minute, about 24.2 rotations per second, filmed at 30 frames per second, appears to turn at about 5.8 rotations per second. Filmed at 24 frames per second, the formula gives about 0.17 rotations per second, a fan that seems nearly frozen. Fan blades are usually symmetric, so the apparent motion depends on the blade count too, but the arithmetic is the same: the wagon wheels that roll backward in old Westerns are aliasing in film.
Harmonics make it messier
Interference is rarely a pure tone
Mains interference usually arrives with harmonics: multiples of the base frequency produced by rectifiers, dimmers and switching supplies. Each harmonic folds on its own. For 60 Hz mains and its first five multiples:
| Sampling rate | 60 Hz | 120 Hz | 180 Hz | 240 Hz | 300 Hz |
|---|---|---|---|---|---|
| 100 Hz | 40 | 20 | 20 | 40 | 0 |
| 103 Hz | 43 | 17 | 26 | 34 | 9 |
| 120 Hz | 60 | 0 | 60 | 0 | 60 |
| 240 Hz | 60 | 120 | 60 | 0 | 60 |
All values are apparent frequencies in hertz after sampling.
Reading the table
At 100 Hz, five interference frequencies collapse onto just three apparent ones, including a component at 0 Hz that shows up as a constant offset no filter can tell apart from a real reading. At 103 Hz, the same harmonics scatter to five different low frequencies, some of them slow enough to look like genuine drift in a temperature or pressure log. At 120 Hz, exactly twice the mains frequency, every harmonic lands either on 0 Hz or on 60 Hz, the Nyquist frequency itself. That’s the logic behind sampling at a multiple of the mains frequency, or averaging over a whole number of mains cycles: the interference stops wandering around the band and piles up in predictable places where averaging cancels it.
The quick test, quantified
The table also shows the “change the sampling rate” test in action. Moving from 100 to 103 Hz shifts the 60 Hz alias from 40 to 43 Hz and the 120 Hz alias from 20 to 17 Hz. A real 40 Hz vibration in the measured object would have stayed at 40 Hz at both rates.

The cure: filter before sampling
Why software can’t fix it afterward
Once a signal has been aliased, its false frequency sits in the same band as real signals, and no digital filter can separate them. The MT-002 tutorial states that an antialiasing filter is used in almost all sampling analog-to-digital converter applications to remove unwanted signals before they’re sampled. The filter has to be analog, ahead of the converter.
A simple RC filter, computed
A single resistor and capacitor make a first-order low-pass filter. Its response falls as 1 / √(1 + (f/fc)²), where fc is the cutoff frequency. For a sensor sampled at 1 kHz:
| Cutoff | Loss at 60 Hz | Loss at 500 Hz | Loss at 900 Hz |
|---|---|---|---|
| 50 Hz | −3.9 dB | −20.0 dB | −25.1 dB |
| 100 Hz | −1.3 dB | −14.1 dB | −19.1 dB |
| 200 Hz | −0.4 dB | −8.6 dB | −13.3 dB |
A 100 Hz cutoff, made with a 10 kΩ resistor and a 159 nF capacitor, cuts a 900 Hz interferer to about a ninth of its amplitude before it can alias to 100 Hz. Two such stages in series, buffered so they don’t load each other, roughly double the decibel loss to about −38 dB.
The trade-off
A single RC stage rolls off slowly, so it can’t remove everything above the Nyquist frequency without also dulling the signal below it. That’s why serious data-acquisition systems use steeper filters, sample far faster than the signal needs and then filter digitally, or both. Oversampling pushes the Nyquist frequency high enough that a gentle analog filter has room to work.
Choosing a sampling rate
A practical checklist
- List every frequency that could reach the input, not just the one being measured: mains at 50 or 60 Hz and its harmonics, switching power supplies, motors and radio pickup.
- Sample at least twice the highest frequency of interest, and in practice several times higher.
- Put an analog low-pass filter ahead of the converter, with its cutoff above the signal but well below half the sampling rate.
- For slow signals near AC wiring, average over a whole number of mains cycles.
- When a reading shows an unexplained slow oscillation, compute where nearby interference frequencies would fold with the formula above before blaming the sensor.
Testing a setup
The quickest check is to change the sampling rate slightly. A real signal stays at the same frequency in the logged data. An alias moves, because its apparent frequency depends on the sampling rate.
Sources
- Walt Kester, Analog Devices, “What the Nyquist Criterion Means to Your Sampled Data System Design,” Tutorial MT-002: https://www.analog.com/media/en/training-seminars/tutorials/MT-002.pdf
