Nyquist Sampling Theorem Simulator — Aliasing of Sampled Signals
Adjust the signal frequency f, sampling rate f_s, observation duration and bit depth N with sliders, and obtain real-time values of the Nyquist frequency f_s/2, alias frequency f_alias and quantisation SNR = 6.02N + 1.76 dB. The simultaneous display of continuous sinusoid, sample points and reconstructed wave together with the f to f_alias folding diagram makes anti-aliasing design for A/D conversion, vibration measurement and modal analysis immediately intuitive.
Parameters
Signal frequency f
Hz
Sampling rate f_s
Hz
Observation duration
ms
Bit depth N
bit
Defaults: f = 600 Hz, f_s = 1000 Hz, duration = 50 ms, N = 8 bit. Because f > f_s/2 = 500 Hz the Nyquist condition is violated, so f_alias = |600 - 1*1000| = 400 Hz appears and the quantisation SNR is 6.02*8 + 1.76 = 49.92 dB.
Results
—
Nyquist frequency f_s/2
—
Perceived frequency f_alias
—
Quantisation SNR
—
Sampling state
Continuous wave, sample dots and reconstructed wave
Time t (ms) on the x-axis, amplitude on the y-axis. The thin orange line is the continuous sinusoid sin(2*pi*f*t), white dots are the sample points (interval 1/f_s), and the thick yellow line is the reconstructed wave at the perceived frequency f_alias. When aliasing occurs, the apparent low frequency becomes visible.
Folding from signal frequency f to perceived frequency f_alias
Signal frequency f (Hz) on the x-axis (0-5000), perceived frequency (Hz) on the y-axis. The blue sawtooth is f_perceived(f): identity (slope 1) for f <= f_s/2 and folded back at multiples of f_s above. The yellow marker is the current operating point (f, f_alias).
Theory & Key Formulas
The sampling theorem sets the time-axis discretisation limit, while the quantisation SNR formula gives the noise performance of amplitude discretisation.
$f$ is the signal frequency [Hz], $f_{s}$ the sampling rate [Hz], $f_{N}=f_{s}/2$ the Nyquist frequency. If $f \le f_{N}$ the original signal is uniquely reconstructed and $f_{\text{alias}}=f$; otherwise high-frequency content folds into the baseband as a phantom spectrum. $N$ is the bit count, and each extra bit gives roughly 6 dB of additional SNR.
What is the Nyquist Sampling Theorem Simulator?
🙋
With the defaults f = 600 Hz and f_s = 1000 Hz I get f_alias = 400 Hz. Why does sampling a 600 Hz signal at 1000 Hz make it look like a 400 Hz signal?
🎓
Good question. Half of f_s = 1000 Hz, namely f_N = 500 Hz, is the Nyquist frequency. A 600 Hz signal lies above that limit, so the sample points alone cannot tell whether the original wave was at 600 Hz or at 400 Hz. The folding rule f_alias = |f - round(f/f_s)*f_s| = |600 - 1*1000| = 400 Hz makes that quantitative. In the upper chart you can literally connect the white dots that sit on the orange continuous wave and read off the thick yellow 400 Hz line.
🙋
The lower chart looks like a sawtooth. So sweeping f from 0 to 5000 Hz makes the perceived frequency oscillate up and down?
🎓
Exactly. f_perceived(f) is a triangular folding function with period f_s. For f <= f_N = 500 Hz it is the identity (slope 1) so the signal is recovered as is, then between 500 and 1000 Hz it falls back from 500 to 0, between 1000 and 1500 Hz it climbs again to 500, and so on. Press "Sweep f" to watch the yellow marker glide along the sawtooth. Now bump f_s to 2000 Hz: f_N becomes 1000 Hz and the 600 Hz tone no longer folds. That is what the Nyquist condition f_s >= 2*f_max means in practice.
🙋
The stat card says quantisation SNR is 49.92 dB. What does that have to do with sampling rate?
🎓
Sharp catch. Sampling discretises the time axis, but A/D conversion also discretises the amplitude axis through quantisation. For an N-bit uniform quantiser driven by a sine wave the signal-to-quantisation-noise ratio is SNR_q = 6.02N + 1.76 dB. That gives 49.92 dB at N = 8, 98.08 dB at N = 16 (CD audio) and 146.24 dB at N = 24 (professional audio). Each extra bit buys roughly 6 dB. Real-world systems either use a wider ADC or oversample heavily and dither out the in-band quantisation noise.
🙋
Does this matter in CAE practice, for example in vibration measurement?
🎓
Massively. For modal analysis on rotating machinery, if the band of interest is 0 to 500 Hz you typically pick f_s = 1024 Hz or, more safely, 2048 Hz. To prevent bearing harmonics in the kHz range and gear-mesh peaks at several kHz from folding into the band, an analogue Butterworth or Chebyshev anti-aliasing filter (4th to 8th order, cutoff around 0.4*f_s) is mandatory before the ADC. Skip it and the FRF picks up phantom peaks that get assigned to nonexistent modes - a notorious source of misdiagnosed natural frequencies. That is why the sampling theorem sits at the centre of every CAE measurement front end.
Physical model and key equations
The Nyquist-Shannon sampling theorem fixes the condition under which a continuous signal $x(t)$, sampled with period $T_{s}=1/f_{s}$ to yield $x[n]=x(nT_{s})$, can be perfectly reconstructed.
Here $f_{\max}$ is the highest signal frequency and $f_{N}$ is the Nyquist (folding) frequency. When $f_{s}$ violates this condition, the spectrum $X(f)$ overlaps at integer multiples of $f_{s}$ and folds into the baseband (spectral folding); the perceived frequency becomes
Reconstruction is ideally a sinc interpolation $x(t)=\sum_{n} x[n]\,\mathrm{sinc}(f_{s}(t-nT_{s}))$, approximated in practice by FIR or IIR low-pass filters. For amplitude quantisation with $N$ bits, signal power $A^{2}/2$ and quantisation step $\Delta=2A/2^{N}$ with uniformly distributed noise of variance $\Delta^{2}/12$ give
With the defaults $f=600$ Hz, $f_{s}=1000$ Hz, $N=8$ bit the simulator returns $f_{N}=500$ Hz, $f_{\text{alias}}=400$ Hz and $\mathrm{SNR}_{q}=49.92$ dB, in exact agreement with these expressions.
Real-world applications
Audio A/D conversion: The CD format uses f_s = 44.1 kHz (twice the 20 kHz audible limit plus margin) and N = 16 bit (SNR = 98.08 dB). Plugging f = 20000 Hz, f_s = 44100 Hz and N = 16 into the simulator gives f_N = 22.05 kHz, f_alias = 20000 Hz (no folding) and SNR = 98.08 dB - the direct logical justification of the CD specification. Hi-resolution audio at 96 kHz/24 bit pushes SNR to 146.24 dB and reserves headroom for mastering.
Vibration measurement and modal analysis: Rotating-machinery diagnostics typically targets 0 to 2 kHz, so f_s of 5120 to 10240 Hz (i.e. f_s = 4*f_max) is sampled with an analogue Butterworth low-pass filter (4th order, cutoff 0.4*f_s) that physically removes content above f_s/2. With f_s = 5120 Hz and f_max = 2000 Hz the simulator gives f_N = 2560 Hz, f_alias = 2000 Hz (identity). Without the anti-aliasing filter, a 6000 Hz bearing harmonic would fold to f_alias = |6000 - 1*5120| = 880 Hz and create a phantom mode - a textbook measurement pitfall.
Image processing and display resolution: The 2-D sampling theorem governs pixelisation. Spatial frequencies above 1/(2 px) cycles produce coarse moire patterns. Sub-pixel rendering on LCD panels and the optical low-pass filter in front of camera sensors are physical anti-aliasing devices for spatial sampling. Frame-rate sampling in video (24 fps, 60 fps) is responsible for the well-known wagon-wheel effect, where a fast-spinning wheel appears to rotate slowly or backwards.
Radar and sonar range/velocity ambiguity: In pulse-Doppler radar the PRF (pulse repetition frequency) acts as the sampling rate. Doppler frequencies above PRF/2 alias and corrupt velocity estimates of fast targets. Low PRFs introduce range ambiguity, high PRFs introduce velocity ambiguity, and both are traded off by staggered-PRF schemes. The folding function in this simulator shares the same algebraic structure and offers concise intuition for radar designers.
Common misconceptions and pitfalls
The most frequent misconception is that "f_s >= 2*f_max alone is enough to avoid aliasing". Real signals always carry unintended high-frequency content (mains-harmonic noise, switching transients of digital circuits, RF interference, thermal noise) that lies above the Nyquist limit and inevitably folds. The theoretical inequality is therefore necessary but not sufficient: a physical analogue anti-aliasing filter (typically Butterworth 4th to 8th order with cutoff around 0.4*f_s) must precede the ADC. Once components have folded, no FIR or IIR digital post-processing can disentangle them.
Another widespread belief is that "if perfect reconstruction by sinc interpolation exists, the same can be done at the DAC and recovery is exact". The ideal sinc interpolator requires an infinite, non-causal convolution and cannot be realised. Real DACs use a zero-order hold followed by a reconstruction LPF that approximates the sinc, but always with finite group delay, passband ripple and stopband leakage. Professional gear closes the gap with 4x or 8x oversampling and delta-sigma modulation that pushes quantisation noise out of the audible band.
The third trap is to assume "SNR_q = 6.02N + 1.76 dB is always achievable". This formula assumes (1) a full-scale sinusoid input, (2) uniformly distributed quantisation error, and (3) no DC offset or distortion. In real ADCs, low-amplitude inputs see a 6 dB SNR drop per halving, DNL/INL non-linearities introduce harmonic distortion, and metastability adds jitter noise. The data-sheet ENOB (effective number of bits) is the back-calculated effective resolution and is always smaller than the nominal N - a 14-bit converter with ENOB = 12 (SNR = 74 dB) is perfectly typical.
Frequently asked questions
The Nyquist-Shannon sampling theorem states that a continuous signal whose spectrum is band-limited to f_max can be uniquely reconstructed from its samples if the sampling rate satisfies f_s >= 2*f_max. If this condition is violated, high-frequency components fold back to lower frequencies and aliasing occurs. With the default f = 600 Hz and f_s = 1000 Hz the tool returns Nyquist frequency f_N = 500 Hz; because f > f_N aliasing happens and the perceived frequency becomes f_alias = |600 - 1*1000| = 400 Hz.
Whenever the signal frequency f exceeds the Nyquist frequency f_N = f_s/2, the spectrum folds around integer multiples of f_s and the perceived frequency becomes f_alias = |f - round(f/f_s)*f_s|. With the defaults f = 600 Hz and f_s = 1000 Hz, round(0.6) = 1 gives f_alias = |600 - 1000| = 400 Hz, so a 600 Hz tone is heard as a 400 Hz tone. When f <= f_N this folding does not occur and the original signal is recovered as f_alias = f.
For a uniform N-bit quantiser driven by a full-scale sinusoid, the signal power (A^2/2) and the quantisation noise power (Delta^2/12 with Delta = 2A/2^N) give SNR_q = 10*log10((A^2/2)/(Delta^2/12)) = 6.02N + 1.76 dB. Each extra bit improves SNR by about 6 dB: N = 8 yields 49.92 dB, N = 16 yields 98.08 dB (CD audio), and N = 24 yields 146.24 dB (professional audio). The simulator returns this theoretical value instantly.
Real signals always carry unintended high-frequency content (mains-harmonic noise, rotating-machine harmonics, thermal noise). Without filtering, components above f_s/2 fold into the baseband and corrupt the analysed spectrum with phantom peaks. An analogue low-pass filter (Butterworth or Chebyshev of 4th to 8th order, cutoff around 0.4*f_s) must therefore be inserted before the ADC to physically remove the high frequencies. Once aliasing has happened, no digital post-processing can undo it.