🚧This page is under construction🚧

Sample rate and aliasing

Hello, friend!

This time I want to tell you about sampling rate (or, simply, sample rate) in digital signal processing, and about a perculiar effect called aliasing.

Sample rate

In digital signal processing we work with signals represented as discrete numbers, as opposed to signals encoded as continuously changing electrical voltage or using some other physical phenomena such as air pressure waves or electromagnetic waves.

To convert continuous, so called analog signal into descrete digital signal, a person somewhat familiar with tech or math would intuitively have an idea to measure the analog signal from time to time and write down measured values.
In fact this is, in general, exactly what we do!

In this context, measuring a signal, i.e. taking a sample of a signal, is called sampling.

In general sampling can be performed at some random, irregular intervals. However sampling at steady, equal intervals makes digital processing of such signal much easier.
When the signal is sampled at equal intervals, we can talk about sampling rate, or, simply, sample rate, i.e. the rate at which measurements of the signal occur. This time we will examine this exact case of sampling at equal intervals.
Usually sample rate is measured in Hertz — samples per second.

Here you can see how continuous signal (  blue line) is sampled at equal intervals, which results in samples (  red circles) ending up at different positions along the vertical axis.

Move the slider to change waveform.

Sampled digital signal may result from digitizing analog signal, or from signal generation, which ranges from computing a bunch of sine values to pretty complex simulations.

Anyway, conversion from analog signal, or generating digital signal directly, gives us a sequence of samples.
Your goal may be to use it to analyze the signal with many powerful methods developed in the domain of DSP (i.e. digital signal processing), and in this case we are done here. But you will still benefit from reading on.

Otherwise, often we would like to turn samples back into analog signal.
But given the samples, what should we use to connect the points to make the signal continuous? A step? Straight line?
A Pokemon shape?

Of course, very smart people alread figured it out: we can perfectly reconstruct sampled signal if it is band limited and we use sufficient sample rate (i.e. if we sample often enough).
The theory behind this is called Whittaker–Nyquist–Kotelnikov–Shannon sampling theorem — that's how many people discovered and rediscovered this very useful and important phenomenon.
Let's try to wrap our head around it step by step.

I think looking at how a step can be represented with a sum of sines will help us a lot.

Number of terms:
Move the slider to change the number of series components.

In mathematics any function can be represented as a sum of infinite number of sines and cosines, such a representation is called Fourier series.

For 10000 components it gets really close...

In this particular case we will indeed need infinite number of components, because a step has discontinuity

TODO: describe how band limited signal can be perfectly reconstructed from samples using lowpass filter

OK
all kinds of mess
Move the slider to change frequency of the wave.

TODO: describe how non-linear distortion may create harmonics with higher frequencies

Color scheme:
Spectrum
DC
½ Nyquist
Nyquist
Nyquist
Spectrogram
½ Nyquist
DC

TODO: describe what is aliasing and how oversampling helps to reduce it

Color scheme:
Oversampling
Nyquist
Resulting signal spectrogram
½ Nyquist
DC
Nyquist
Oversampled signal spectrogram
½ Nyquist
DC
0 dB
DC
-90 dB
½ Nyquist
Nyquist

TODO: describe what to do or to look for in practice

If you are just starting to explore digital signal processing, I hope this explainer was useful for you and you developed better intuition about about conversion between analog and digital signal, sample rate, and aliasing.

If you already have experience with DSP, I hope you had fun playing with all the toys on this page.

See you some other time!
Pavel

Share

KISS FFTExternal Link icon by Icons8
These links will open in new tabs.