Skip to content

Signal Example — Sampling & Reconstruction

Interactive demonstration of the Nyquist–Shannon sampling theorem.

This demo shows how sampling rate affects the reconstruction of a sine wave.

Signal Example 1

What it shows

FeatureDescription
Original signalA "continuous" sine wave at the chosen frequency
Sampled pointsThe discrete samples taken at the chosen sampling rate
Linear reconstructionStraight-line interpolation between samples
Sinc reconstructionWhittaker–Shannon (ideal) interpolation

Linear reconstruction connects adjacent samples with straight lines. It is simple but introduces distortion — particularly at low sampling rates relative to the signal frequency.

Sinc reconstruction uses the Whittaker–Shannon interpolation formula to reconstruct the signal exactly (within the Nyquist limit).

When the sampling rate falls below twice the signal frequency, the signal cannot be recovered: the sampled waveform appears at the wrong frequency — a phenomenon known as aliasing. Modern EEG systems typically sample at 256–2048 Hz, which is far above the Nyquist limit for brain signals of interest (usually < 100 Hz), ensuring faithful digitisation.

Things to Try

  • Start with a sampling rate well above Nyquist (e.g. 10× the signal frequency) and observe that both methods agree with the original signal.

  • Gradually reduce the sampling rate toward and then below the Nyquist limit (~2× the signal frequency) to show reconstruction breakdown and aliasing.

  • Enable both reconstructions simultaneously to highlight the superiority of sinc interpolation near the Nyquist limit.

Controls

ControlRangeDescription
Duration1–10 sLength of the displayed signal
Signal Frequency1–100 HzFrequency of the underlying sine wave
Phase Angle−π to πPhase offset of the sine wave
Sampling Rate1–300 HzNumber of samples per second
☐ LinearToggle linear interpolation overlay
☐ SincToggle sinc reconstruction overlay

See Also

Code

julia
using EegFun
EegFun.signal_example_sampling()