5. Data quantization#
Uniform time sampling#
So far we have dealt with continuous data \(x(t)\), but in experimental work we almost always encounter discrete values, which are typically captured by uniform time sampling \(x(n\,\Delta t)\), where \(\Delta t\) is the sampling time (period) (\(f_s=1/\Delta t\) is the sampling frequency).
In understanding sampled data, we help ourselves with uniformly sampled data \(x_s(t)\), which are the product of the continuous data \(x(t)\) and a train of impulses \(i(t)\):
where:
The Fourier transform of \(x_s(t)\) is:
In the transition to the last line, we use the sifting property of the Dirac delta function (see the chapter Properties of the Dirac delta function).
The key consequence of the above derivation is: for sampled data, the integral is transformed into a sum of sampled values (multiplied by a harmonic modulation).
We also find that the Fourier transform of the uniformly sampled series \(X_s(f)\) repeats (is periodic) with frequency \(1/\Delta t\), which we prove as follows:
where \(r\) is an arbitrary integer. We therefore conclude:
Note
The Fourier transform of data \(x(t)\), sampled with period \(\Delta t\), is defined as the sum:
and is periodic in the frequency domain with frequency \(1/\Delta t\):
Let us now try to derive the inverse Fourier transform; first we multiply the expression in the frequency domain by \(\mathrm{e}^{\textrm{i}\,2\pi\,f\,p\,\Delta t}\) (here \(p\,\Delta t\) is the time at which we are interested in the value in time \(x(p\,\Delta t)\)) and integrate over the frequency \(f\):
where we integrated only over one period in frequency (it would not make sense to integrate over more, since \(X_s(f)\) is a periodic function).
We rewrite the above expression into:
Note
We have thus derived the inverse Fourier transform:
Aliasing#
Aliasing (also frequency folding) is a phenomenon in which a frequency in the signal is identified incorrectly; the reason for this is inappropriate sampling of the time signal. Let us look at the details: the train of impulses \(i(t)\) can be treated as periodic data with period \(\Delta t\), and described by a Fourier series:
where:
It follows:
The Fourier transform of \(i(t)\), defined with the help of Fourier series:
Above, we used the property of the Dirac delta function \(\int_{-\infty}^{+\infty}\mathrm{e}^{\pm\textrm{i}\,2\pi\,a\,t}\,\textrm{d}t= \delta(a)\) (see the chapter Properties of the Dirac delta function). The Fourier transform of \(i(t)\) is therefore periodically repeating in the frequency domain with frequency period \(1/\Delta t\).
Let us now look at the relation between \(X(f)\) and \(X_s(f)\):
How do we interpret the above derivation? If we have time-sampled data \(x_s(t)\), which in the frequency domain leads to \(X_s(f)\), then at a certain frequency \(f\) we have the content of the sum of the continuous data \(X(f)\) at the frequencies \(f-n/\Delta t\), where the integer \(n\) goes from \(-\infty\) to \(+\infty\). In practice this means that the content of the actual (continuous) signal from the frequency range outside the range \([-1/(2\Delta t), +1/(2\Delta t)]\) is folded and overlaps into the frequency range \([-1/(2\Delta t),\,+1/(2\Delta t)]\); see the example below.
Example: Gaussian impulse#
Here we will look at time sampling and aliasing on the example of a Gaussian impulse/window (see the chapter Gaussian impulse), which is defined in the time and frequency domains as:
Another example of aliasing is the example below, where we consider harmonic data. When the sampling frequency fs is too low relative to the frequency of the harmonic data f (\(f>fs/2\)), the actual frequency is folded into the frequency range up to fs/2. In the code below, try slowly raising the frequency of the sine signal f toward (and above) the sampling frequency fs.
Preventing aliasing#
If \(f_s=1/\Delta t\) is the sampling frequency, then aliasing can be avoided by using a low-pass filter at the frequency:
Here it is important to use an analog filter before performing the time sampling. The frequency \(f_{np}\) is also called the Nyquist frequency.
Data quantization: converting continuous data into discrete data#
For computer processing, we must convert the measured continuous data into discrete numerical values, captured at a certain sampling frequency. Acquisition cards today allow relatively fast acquisition (at least 100 kHz) at a relatively large dynamic depth (at least 24 bits). Here we will look in more detail at the dynamic depth, which represents the number of discrete levels at which the acquisition card distinguishes the analog data.
The representation of numbers in a computer is of finite precision; today’s computers usually use 64-bit precision, which is significantly more precise than what acquisition measurement cards allow.
Let us look at the following example, where we consider a sinusoid. If we use a 24-bit card and the typical measurement range [-10, 10], the difference between two quantization levels is approximately 1e-6, which is entirely sufficient for most measurements. The ratio between the smallest and the largest value that we can measure on a particular acquisition card is called the dynamic range or also the dynamic depth.
If, however, we use a system with a lower dynamic range, then we must pay very close attention to the measurement range in connection with the dynamic range, and possibly amplify the measured data. Such an example is the sinusoid below, which we quantize on two ranges ([-1, 1] and [-5, 5]) with 4-bit precision (16 levels).
When measuring, we must also watch out for clipped data (clipping), when the measurement range is too small (example below: [-0.5, 0.5]).
Note: the code for the figure below also includes an example where noise can help us measure quantities that are smaller than the quantization level.
Signal-to-noise ratio#
The difference between the quantized and the actual value can be treated as random noise \(e\) with a uniform distribution within the quantization step. The standard deviation of such noise is defined as (Shin and Hammond [2008], p.: 133):
where \(A\) is the total span of the quantization range and \(b\) the number of quantization bits, without the sign bit. For 24-bit quantization on the range from -10 to 10 (\(A=20\)), the standard deviation of the noise is:
In evaluating the proportion of useful information relative to noise, we help ourselves with:
Note
the signal-to-noise ratio:
where \(\sigma_x^2\) and \(\sigma_e^2\) represent the power of the useful information (the signal \(x\)) and of the noise (\(e\)).
If we assume that \(\sigma_x=A/4\) (to prevent clipping of the data), we derive:
In the case of 12-bit quantization, \(b=11\) and we have approximately 65 dB of dynamic range available, while in the case of 24-bit quantization the range would theoretically be approximately 137 dB. In practice we also deal with other sources of noise, which cause the SNR values to be significantly lower. Below, an idealized example of noise and of data not burdened with noise is shown.