JOVANA
Explore Library Glossary Getting Started Three Levels Fields How it works Mission
Join the mission
All guides

Aliasing, Nyquist, and the Sampling Theorem

A spinning wheel that drifts backward in a movie, a tone that comes out the wrong pitch — these are the same bug, and the discrete Fourier transform makes it precise. Learn why a finite set of samples can only ever see frequencies below the Nyquist limit, and exactly when those samples are enough to recover the whole signal.

Two frequencies, one column of samples

In the first two guides of this rung you met the discrete Fourier transform, which turns N evenly spaced samples into N frequency coefficients, and the Cooley-Tukey fast Fourier transform, which computes those coefficients in O(N log N) instead of O(N^2). Both took the samples as a given. This guide asks the prior question that signal processing cannot skip: when you sample a continuous wave at a fixed rate, what exactly have you captured — and what have you silently thrown away? The answer is sharper and more surprising than most people expect.

Start with the cleanest possible experiment. Sample the pure cosine cos(2 pi f t) at the instants t_n = n/F, where F is the sampling rate (samples per second) and n = 0, 1, 2, .... A frequency f and a frequency f + F land on EXACTLY the same samples, because adding F to the frequency adds a whole integer 2 pi n to every angle, and cosine does not notice a full turn. The two continuous waves are completely different, yet they pass through every sample point in lockstep. Once you hold only the samples, you cannot tell them apart — and neither can the DFT.

This is aliasing: under a fixed sampling rate, a high frequency wears the disguise — the alias — of a lower one. The whole infinite ladder of frequencies f, f + F, f + 2F, f - F, ... collapses onto a single DFT coefficient. The aliasing phenomenon is not a flaw in the DFT or a rounding artefact; it is a hard, exact consequence of having only discrete samples of a continuous world. You did not lose accuracy — you lost the ability to ask the question.

The wagon wheel and the half-rate ceiling

You have seen aliasing with your own eyes. In old films a wagon wheel sometimes spins backward, or hangs still while the wagon races forward. The film samples the scene 24 times a second; if a spoke advances almost a full gap between frames, your brain reads it as having slipped slightly BACKWARD instead. A fast forward rotation is aliased to a slow backward one — the visual twin of f + F masquerading as f. A strobe light tuned to a fan's blade rate freezes the blades for the same reason: the sampling instants and the motion conspire.

So where is the safe ceiling? Run the disguise the other way. With sampling rate F, the frequencies a real-valued signal can show are squeezed into a band of width F, and because a real cosine carries both +f and -f, the honestly distinguishable range runs only from 0 up to F/2. That half-rate boundary is the Nyquist frequency, the Nyquist frequency. Any component below it keeps its true identity in the samples; any component above it folds back down — reflects across F/2 — and shows up wearing the costume of a lower frequency. The Nyquist frequency is the exact line between what your samples can faithfully report and what they will lie about.

Reading aliasing off the DFT spectrum

The DFT makes this folding completely concrete. With N samples taken at rate F, coefficient X_k corresponds to frequency k F/N for k = 0, 1, ..., N-1. The catch is the wrap-around you already saw in the periodicity of the DFT: index N - k is not a brand-new frequency but the negative of index k. So the meaningful spectrum is folded in the middle — bins 0 up to N/2 carry the positive frequencies climbing to Nyquist, and the upper bins are their mirror image, the negative frequencies. Anything the continuous signal held above F/2 has already been added INTO these same bins before you ever see them. The DFT cannot unmix what sampling already merged.

F  = 1000 Hz sampling rate,  N = 1000 samples
bin width  =  F/N  =  1 Hz per bin

true signal: a single tone at 700 Hz
700 Hz  >  Nyquist = F/2 = 500 Hz   ->  it ALIASES

folded frequency = F - 700 = 1000 - 700 = 300 Hz
=> energy appears in the 300 Hz bin, NOT 700 Hz
   (700 reflects across 500 down to 300)
A 700 Hz tone sampled at 1000 Hz shows up as a phantom 300 Hz peak. Reflect any frequency above F/2 back across the Nyquist line to find its alias.

This is also why the cure must come BEFORE sampling, not after. You cannot un-fold the spectrum once the energy has landed in the wrong bin — that information is gone for good. So real analog-to-digital converters put an anti-aliasing filter in front: an analog low-pass filter that physically removes everything above F/2 before the sampler ever looks. The 700 Hz tone is killed in hardware, so it can never sneak into the 300 Hz bin. The honest rule is blunt: filter first, then sample; there is no software fix downstream.

The sampling theorem: when samples are enough

Now flip the mood from warning to promise. Suppose a signal is band-limited — it genuinely contains NO frequency at or above some ceiling B. The Nyquist-Shannon sampling theorem, the sampling theorem, makes a remarkable claim: if you sample faster than 2B, the discrete samples lose nothing at all. The entire continuous signal — every value at every instant between the samples — can be reconstructed EXACTLY from the discrete dots. This is not an approximation that improves with more dots, like the finite differences you saw earlier; it is an exact identity, the moment the rate clears 2B.

How can dots determine a continuous curve? Because band-limiting is a fierce constraint. A signal with no energy above B cannot wiggle arbitrarily fast between samples — its values are tied together. The reconstruction formula spells this out: place a sinc function (sin(pi x)/(pi x), shaped like a central hump with ripples dying away on both sides) at each sample, scaled by that sample's height, and sum them. Each sinc is exactly zero at every OTHER sample instant, so the sum hits each dot perfectly and the band-limit forces the smooth, unique interpolant in between. It is the continuous cousin of the trigonometric interpolation that the DFT performs on a finite grid.

The fine print: leakage and the honest limits

The sampling theorem is beautiful and also idealized, and a climber should know exactly where it bends. First, perfectly band-limited signals do not exist in nature — a signal of finite duration cannot have a strictly finite frequency range, so there is always a little energy above any B, and thus always a sliver of residual aliasing. Second, the exact sinc reconstruction needs ALL the samples, stretching infinitely in both directions, which no real machine has. We always work with a finite window, and that truncation has its own cost.

That cost has a name: spectral leakage. Cutting a signal off at the ends of a finite record is the same as multiplying it by a rectangular window, and a sharp rectangular edge is rich in high frequencies. A single pure tone that does not land exactly on a DFT bin centre therefore does not give one clean spike — its energy SMEARS, or leaks, into neighbouring bins. The spectral leakage effect is distinct from aliasing (which is about sampling rate) but lives next door: both blur the spectrum and both arise from the gap between the clean continuous theory and the finite discrete reality.

The standard mitigation is a window function — multiply the record by a smooth taper (Hann, Hamming, Blackman, and friends) that eases the signal gently to zero at both ends instead of chopping it. The window function softens the edges, which shrinks the leakage skirts dramatically, at the honest price of a slightly wider, blurrier main peak. There is no free lunch: you trade sharp resolution for low leakage, and the right window depends on whether you care more about separating two nearby tones or about spotting a faint tone beside a loud one.

What to carry up the ladder

Tie the three ideas together. Sampling collapses an infinite family of frequencies onto each DFT bin — that is aliasing. The boundary of honesty sits at half the sampling rate — that is the Nyquist frequency. And if the signal stays strictly below that line, the samples lose nothing and the continuous wave can be rebuilt exactly — that is the sampling theorem. Every one of these is exact mathematics, but every real system meets them through imperfect filters, finite windows, and floating-point arithmetic, so the digits you actually get are still an approximation. You will lean on all of this immediately in the next guide, where the same DFT machinery powers fast convolution.