 Sampling theorem

Aliasing effect

Downsampling

Upsampling

# Sampling theorem, basics

## Sampling theorem

Abundant material relating to sampling can be found in the special literature, including Internet. In this subject, the most important work can be connected to the name of Nyquist and Shannon.
In sampling, one of the most important issues is determining the sampling frequency. It can be generally said that the sampling frequency must be at least twice of the maximum frequency content of the signal. This way we can avoid the overlap, the original signal can be restored with minimal distortion. In order to provide bandlimited signal to the input of ADC (analog digital converter), an antialiasing filter should be used. Correct sample rate selection Spectra at correct sample rate selection

The most important criteria for choosing a sampling frequency is to avoide overlaps. In case of overlapping components are generated which are not included in the original signal. These components can cause a significant distortion, so the original signal can be restored with only significant distortion. Incorrect sample rate selection Spectra at correct sample rate selection

In case of band-pass filtered signals under certain conditions, the sampling frequency can be chosen to twice of the bandwidth (fs >2 * B). See downsampling.

## Aliasing effect

Aliasing effect occurs if the signal frequency is equal or greater than half of the sampling frequency. The effect is that the frequency of components between fs/2 – fs will change to lower value. See picture below. Original signal Sampled signal – Aliasing distortion

As a result of sampling, f1’ and f2‘ components are formed, which are not included in the original signal.

f1’ = fs – f1
f2’ = fs – f2

The aliasing effect can be used for useful purposes, such as reducing the sampling frequency at small B/fs ratio, decomposing HP bands in wavelet packet transformation, etc.

## Downsampling

The expression of downsampling is spread especially in the wavelet transformation, with the meaning of halving of the sampling frequency. Downsampling is a special case of decimation, when the decimation rate is 2. The theory of decimation is well known in digital signal processing. Downsampling

The first stage of downsampling is a low pass filter, thus ensures compliance with the sampling theorem. The second step halves the sampling frequency in a way that every second sample is omitted. The corner frequency of the low pass filter is set to a quarter of the sampling frequency.
The distortion of downsampling is basically determined by the transfer characteristics of the low pass filter. The more similar the characteristic of the low pass filter to the ideal (brickwall) is, the smaller is the aliasing distortion. The case which is very close to ideal could be achieved with very high taps number, but we try to avoid that because of the high computational demand. Spectra before downsampling Spectra after downsampling

Theoretically the overlap can also be reduced if the corner frequency of the low pass filter is set to smaller than fs/4, but in this case a gap is formed, which means that a certain part of the signal is lost during the decomposition. Therefore this method is not recommended.

There are cases when the low pass filter can be omitted. Such thing can be seen in the figures below. Bandlimited signal spectra Bandlimited signal spectra Bandlimited signal spectra

## Upsampling

The expression of upsampling is spread especially in the wavelet transformation with the meaning of the sampling frequency doubling. Upsampling is a special case of interpolation, when the interpolation rate is 2. The theory of interpolation is well known in digital signal processing. Upsampling

The first stage of upsampling is an interpolation, which means that a zero is inserted between every two samples, so the sampling frequency is doubled. Due to the change of the sampling frequency, spectrum repetitions occur, which can be filtered off with the low pass filter in the second stage. The corner frequency of the low pass filter is set to a quarter of this increased sampling frequency.

In practice the interpolation is also very useful to determine the value between two sampling points in time series. Mathematics knows other interpolation methods such as spline interpolation which, is similar in the effect but different in the operating principles.

Example: in many cases, when very narrow R or S waves are sampled in ECG signal processing, the wave peaks are cut due to the insufficiently high sampling frequency. This phenomenon can be eliminated subsequently by interpolation if necessary.  R peak before upsampling

R peak after upsampling

With using interpolation the wave peaks are more accurately determined. Figures made with the help of Filter Scope module of Filter Design program. 