Sampling, Nyquist & Aliasing
Sampling replicates a signal's spectrum at every multiple of the sample rate; aliasing is what happens when those copies overlap and fold high frequencies irreversibly onto low ones. Shannon's exact statement, the folding arithmetic, anti-alias filtering, oversampling, clock jitter, deliberate undersampling — and the same failure in metrics pipelines and images.
Sampling is not "taking snapshots" — in the frequency domain it is replication. Multiplying a signal by an impulse train convolves its spectrum with an impulse train, producing a copy of the whole spectrum centred on every multiple of the sample rate. Everything about Nyquist follows from one question: do those copies overlap? If they do, the overlapping energy adds into the baseband as legitimate-looking low-frequency content that no later processing can separate out, and the damage is done at the instant of sampling. This entry is about the mechanism, the arithmetic of where a given frequency lands, and the several very different-looking systems — converters, cameras, metrics pipelines — that fail in exactly the same way.
The mechanism: sampling replicates the spectrum #
Model ideal sampling as multiplication by an impulse train with . Multiplication in time is convolution in frequency, and the Fourier transform of an impulse train is another impulse train, so:
The sampled signal's spectrum is the original spectrum, scaled by , repeated forever at spacing . Nothing is lost yet — the baseband copy is still intact provided the copies do not overlap. That is the entire content of the sampling theorem.
Modern statements make the inequality strict: if for , then is uniquely determined by provided . The strictness is not pedantry — see the boundary case below.
| Term | Meaning | Depends on |
|---|---|---|
| Nyquist rate | highest frequency present | the signal |
| Nyquist frequency (or Nyquist limit) | the sampler | |
| Nyquist zone | the band | the sampler |
These get swapped constantly in conversation. "Sample above Nyquist" is ambiguous; "sample above the Nyquist rate" is not.
Aliasing is folding, and here is where things land #
When a component sits above , one of the shifted replicas lands inside the baseband. The resulting apparent frequency is the distance to the nearest multiple of :
Concretely, with Hz (Nyquist frequency 500 Hz):
| Input frequency | Appears at | Nyquist zone | Spectrum |
|---|---|---|---|
| 100 Hz | 100 Hz | 1 | correct |
| 400 Hz | 400 Hz | 1 | correct |
| 600 Hz | 400 Hz | 2 | inverted |
| 900 Hz | 100 Hz | 2 | inverted |
| 1000 Hz | 0 Hz (DC) | 3 | upright |
| 1100 Hz | 100 Hz | 3 | upright |
| 1900 Hz | 100 Hz | 4 | inverted |
Two structural facts fall out of that table. Even Nyquist zones arrive spectrally inverted — sweep the input upward and the alias sweeps downward. And 100 Hz, 900 Hz, 1100 Hz and 1900 Hz are indistinguishable after sampling: they produce bit-identical sample sequences. There is no recovery algorithm, no ML model, no clever resampler that can tell them apart, because the information is not merely obscured — it is not present.
The acquisition chain #
flowchart LR X["x(t)"] --> AAF["Anti-alias LPF"] AAF --> SH["Sample & hold<br/>clock fs ± jitter"] SH --> Q["Quantizer<br/>N bits"] Q --> D["x[n]"] D --> DSP["DSP / storage"] DSP --> DAC["DAC<br/>zero-order hold"] DAC --> REC["Reconstruction LPF<br/>+ sinc droop fix"] REC --> Y["y(t)"]
Two filters, not one. The anti-alias filter is analog and mandatory — it must run before the sampler, because after the sampler the aliased energy is already indistinguishable from signal. The reconstruction filter on the output side removes the spectral images that the DAC emits above .
Anti-alias filtering in practice #
The filter needs to pass the band of interest and be far enough down at that folded energy sits below the converter's noise floor — for a 16-bit converter, that means roughly 96 dB of stopband rejection.
This is brutally hard at CD rates. The Red Book chose 44.1 kHz for reasons that had nothing to do with signal processing: early digital audio was stored on video tape via PCM adaptors, and three samples per active line lands on the same number under both frame geometries — for NTSC and for PAL. (NTSC's actual 59.94 Hz color field rate gives 44,056, the rate early Sony PCM units used; 44,100 is the PAL-derived number that the Red Book standardised.) That leaves the transition band between a 20 kHz passband edge and a 22.05 kHz Nyquist frequency: 2.05 kHz, about 0.14 octave, in which to fall 96 dB. A pure analog brick-wall filter of that steepness is a high-order elliptic design with severe passband ripple and violent phase distortion near the corner. Hence: nobody builds one any more.
| Rate | Nyquist freq. | Typical use | Transition band above 20 kHz |
|---|---|---|---|
| 8 kHz | 4 kHz | narrowband telephony | — |
| 16 kHz | 8 kHz | wideband voice codecs | — |
| 44.1 kHz | 22.05 kHz | CD audio | 2.05 kHz |
| 48 kHz | 24 kHz | video, pro audio | 4 kHz |
| 96 kHz | 48 kHz | production, easy filtering | 28 kHz |
| 192 kHz | 96 kHz | production / measurement | 76 kHz |
The last column is the real argument for high sample rates in production, and it is a filter design argument, not an audibility one: at 96 kHz a gentle analog filter with negligible in-band phase distortion suffices, and the steep part of the job moves into a linear-phase digital FIR filter running before decimation.
Oversampling and delta-sigma #
Oversampling attacks two problems at once. Spreading the same total quantization noise power over a wider band leaves less of it inside the band of interest: SNR improves by 3 dB (half a bit) per doubling of . That alone is a bad deal — reaching 16-bit resolution from a 1-bit quantizer by oversampling alone would need a factor of , which is not realizable.
Delta-sigma converters add noise shaping: the modulator's integrator acts as a lowpass for the signal and a highpass for the quantization noise, pushing noise out of the band of interest rather than merely diluting it. Total noise power is unchanged; its distribution is not. A first-order modulator yields 9 dB per doubling, a second-order modulator 15 dB per doubling.
Reconstruction and the zero-order hold #
Ideal reconstruction convolves with a sinc, which is infinitely long and non-causal — not buildable. Real DACs hold each sample for one period, a zero-order hold, whose frequency response is
This is not flat: it droops to dB at the Nyquist frequency, and its nulls at multiples of only partly suppress the spectral images. Competent DACs compensate with an inverse-sinc digital filter and an analog reconstruction filter; oversampling DACs push the images far away first, for the same reason oversampling ADCs do.
Jitter: the other way to break sampling #
The theorem assumes samples are taken at exactly . Real clocks have RMS timing uncertainty — external clock jitter and the converter's internal aperture jitter combining as . A timing error becomes an amplitude error proportional to the signal's slew rate, so the penalty grows with input frequency, not with sample rate:
| Input frequency | RMS jitter | SNR ceiling | ENOB ceiling |
|---|---|---|---|
| 1 MHz | 1 ps | 104 dB | 17.0 bits |
| 10 MHz | 1 ps | 84 dB | 13.7 bits |
| 100 MHz | 1 ps | 64 dB | 10.3 bits |
| 250 MHz | 1 ps | 56 dB | 9.0 bits |
| 250 MHz | 100 fs | 76 dB | 12.3 bits |
| 1 GHz | 100 fs | 64 dB | 10.3 bits |
ENOB from dB. The practical reading: a 14-bit ADC digitizing a 250 MHz IF with a 1 ps clock delivers about 9 effective bits regardless of its datasheet. Conversely, an ADC with 70 dB SNR at a 100 MHz input needs total jitter under fs. At high input frequencies the clock, not the converter, is the design.
Undersampling on purpose #
Nyquist's condition is about bandwidth, not about the highest frequency — Shannon says so directly, noting that the result holds for a band that does not start at zero, provable by translation. A signal occupying 88–108 MHz has 20 MHz of information in it, and sampling it at 43.2 MHz can capture all of it, with a replica folding neatly into baseband. This is bandpass sampling, and it is how software-defined radios skip an analog mixing stage.
The valid rates form disjoint zones, not a single "above " region:
For FM broadcast (, MHz, MHz): , so can be 1…5. The most aggressive zone, , is MHz — an 800 kHz-wide window with zero margin at either edge. Zone gives MHz, so 56 MHz sits comfortably mid-zone. As with odd/even in the folding table, even inverts the spectrum in baseband.
The same failure outside audio #
Metrics, scrape intervals, and phantom trends #
A monitoring pipeline is a sampler. The scrape interval is ; the Nyquist frequency is ; and there is no anti-alias filter anywhere in the standard stack. Prometheus's default scrape_interval is 1 minute, so any periodic behaviour with a period shorter than two minutes aliases. A common 15-second interval buys a 30-second Nyquist period.
Related traps in the same family:
- Phase-locked sampling. A service that pauses for 1 s every 10 s, scraped every 10 s, is sampled at fixed phase: the collector either always lands inside the pause or never does. The gauge reads a constant — either a scary constant or a reassuring one — and both are wrong.
- Rollups are decimation without a proper filter. Rolling 15 s data into 5 min averages is decimation by 20. The preceding box average is a rectangular window whose sidelobes fall only to about −13 dB, so out-of-band energy leaks into the retained band rather than being removed. Correct decimation requires a real lowpass first: downsampling by sums shifted copies of the spectrum, so the band must be limited to before the decimation, not after.
- Min/max rollups are not filters at all. They are nonlinear, so no spectral argument applies. They are excellent for "did it ever spike" and useless as a signal: you cannot compute a meaningful rate, derivative, or percentile from a max-rollup series.
- Query windows near the sample interval. The Prometheus guidance to make a
rate()range at least 4× the scrape interval is not literally Nyquist — the stated reasons are ingestion races and tolerating a failed scrape — but it is the same discipline: never operate at the edge of your sampling resolution, because the edge is exactly where the estimator becomes unstable.
Images: moiré and the optical lowpass filter #
A sensor samples space instead of time, so its Nyquist frequency is fixed by the pixel pitch at 0.5 cycles/pixel by definition. Detail finer than that folds down into coarse patterns: repetitive subjects (fabric, brickwork, roof tiles, a distant fence) produce moiré, and non-repetitive edges produce jaggies. Many cameras therefore fit an optical lowpass filter — a birefringent anti-alias filter directly in front of the sensor — which works exactly as it must, by blurring the image slightly before sampling. It trades sharpness for correctness, which is why some bodies omit it and accept the moiré risk.
Bayer color filter arrays make it worse: like-colored photosites are spaced further apart than the final image's pixels, so the red and blue channels alias at roughly half the luminance Nyquist frequency, and the artefact appears as color moiré. The rendering-side analogue is antialiasing, where the sampler is the rasterizer and supersampling is oversampling by another name.
Time: wagon wheels and strobes #
Film sampled at 24 fps looking at a 12-spoke wheel sees a spoke pattern that repeats every 30° of rotation. At 120 rpm (2 rev/s) the spoke frequency is exactly 24 Hz, aliasing to DC — the wheel appears frozen. At 125 rpm the spoke frequency is 25 Hz, aliasing to +1 Hz, and the wheel appears to creep forward at 30°/s; at 115 rpm it is 23 Hz, aliasing to −1 Hz, and the wheel rotates backwards. Same arithmetic as the folding table, applied to a camera shutter. The same effect is used deliberately by timing strobes to "stop" rotating machinery.
What to actually do #
Sources
- paperCommunication in the Presence of Noise (Shannon, Proc. IRE 37(1), 1949)
- docsMIT 6.003 Signals & Systems, Lecture 21: Sampling
- docsDownsampling and Aliasing (J. O. Smith, Spectral Audio Signal Processing, CCRMA Stanford)
- docsJitter vs SNR for ADCs (TI Precision Labs, TIPL 4704)
- docsDemystifying Delta-Sigma ADCs (AN1870)
- articleUndersampling / bandpass sampling — allowed sample-rate zones
- articleSampling bandpass signals (J. Hoffmann, DSPRelated)
- docsNyquist frequency, aliasing and color moire (Imatest)
- articleWhat range should I use with rate()? (Robust Perception)
- docsPrometheus configuration reference