Sampling Rate Demonstration

Sampling Rate Demonstration

Sampling Rate Demonstration

Explore how sampling rate affects signal reconstruction and aliasing

Original Signal
Sampled Points
Info

Understanding Sampling Theory

What is Sampling?

Sampling is the process of converting a continuous signal (like a sound wave or analog voltage) into a discrete signal by measuring it at regular intervals. The rate at which we measure the signal is called the sampling rate or sampling frequency.

The Nyquist-Shannon Sampling Theorem

This fundamental theorem states that to accurately reconstruct a signal, you must sample it at least twice the frequency of the highest frequency component in the signal.

Sampling Rate ≥ 2 × Signal Frequency

The minimum sampling rate (2× the signal frequency) is called the Nyquist Rate, and half the sampling rate is called the Nyquist Frequency.

Nyquist Frequency = Sampling Rate ÷ 2

What is Aliasing?

Aliasing occurs when a signal is sampled at a rate that is too low (below the Nyquist rate). When this happens, high-frequency signals become indistinguishable from low-frequency signals, creating false or “alias” frequencies in the reconstructed signal.

Think of it like a wagon wheel in a movie that appears to spin backward or slowly forward even though it’s actually spinning quickly. This happens because the camera’s frame rate (sampling rate) is too low to capture the wheel’s true motion.

Practical Examples

  • Audio: CD quality audio uses 44,100 samples/second because humans can hear up to ~20,000 Hz. The Nyquist rate for 20,000 Hz is 40,000 samples/second, so 44,100 provides a safety margin.
  • Video: Movies at 24 fps can create aliasing effects with fast-moving objects or rotating wheels.
  • Measurement Systems: Oscilloscopes and data acquisition systems must sample fast enough to capture the signals they’re measuring.

Experiment with the Demo

Try these experiments to see aliasing in action:

  • Set signal frequency to 40 Hz and sampling rate to 100 samples/sec. You’re just above the Nyquist rate.
  • Set signal frequency to 60 Hz and sampling rate to 100 samples/sec. You’re below the Nyquist rate – notice the aliasing!
  • Set signal frequency to 45 Hz and sampling rate to 100 samples/sec. The sampled signal appears as if it’s 5 Hz (the alias frequency).

Key Takeaways

  • Always sample at least 2× faster than your highest frequency component
  • Undersampling creates aliasing artifacts that cannot be removed
  • In practice, use a sampling rate 2.5-4× the highest frequency for better reconstruction
  • Use anti-aliasing filters before sampling to remove frequencies above the Nyquist frequency