Sampling and Quantization
Sampling
Under certain conditions, a continuous-time signal can be completely
represented by and recoverable from knowledge of its values, or samples.
This somewhat surprising property follows from a basic result that is
referred to as the sampling theorem.
If the signals are bandlimited, it is possible to reconstruct the original
signal from the samples
Conditions: the sampling rate is at least twice the higher frequency
contained in the signal - Shannon Nyquist Sampling Theorem.
Sampling
To simplify our understanding of the conversion from analog to digital
signal, we will start from the simple periodic analog signal.
Sampling
This is a continuous function of time.
No matter how close two time intervals are, you wouldn’t be able to
find a single break in the signal.
A clear advantage of digital signal over analog signal is in its storage
capabilities.
Sampling
All the hard drives in the world could not accommodate the number of
unique and distinct values this sign function can produce.
We only have to save enough values which closely resemble the original
signal.
Break apart the waves to make it discontinuous – to provide values only
at certain points in time.
Sampling
Sampling
What’s the right number?
How many samples are enough to accurately represent this wave?
Continuous to discrete signal conversion is governed by the Nyquist
Shannon Sampling Theorem.
Sampling
Shannon’s version of the statement:
If a function 𝑥(𝑡) contains no frequencies higher than 𝐵 hertz, then it can
be completely determined from its ordinates at a sequence of points
spaced less than 1/(2𝐵) seconds apart.
Nyquist Shannon Sampling Theorem:
Any band limited continuous-time signal can be accurately converted to
and from digital signals when sampled at a rate, at least twice as high as
the highest frequency component of the waveform.
Sampling
The sampling theorem states two important facts:
i. To represent an analog signal into digital domain, the number of
samples needed per second should be more than twice the highest
frequency represented by the signal.
ii. The analog signal needs to be band limited to the highest frequency
and cannot contain frequencies above that.
Sampling
If these sampled waveform (with 3
sample points) is converted back to
analog signal, the signal could be
rendered in several different ways.
Sampling
If the 1 Hz signal is sampled at 40 Hz sampling frequency, would you get
a more accurate representation?
The answer is – no.
Sampling
Both 3 Hz and 40 Hz sampled waveform not only produces same analog
signal when reconverted back, but produces signal which is
indistinguishable from the original analog signal
Sampling
This is possible because of the band limited condition of the signal.
Limiting of a signal’s frequency domain representation to zero above a
certain frequency.
Sampling
A theoretical low pass filter only allows passage of frequencies lower
than a set threshold and blocks all frequencies higher than the threshold.
Practical filters can’t cutoff abruptly at a certain frequency – rather ramp
down smoothly.
Sampling
Audacity Demonstration:
i. Signal Frequency = 1 kHz, Sampling rate = 8 kHz.
i. Signal Frequency = 4 kHz, Sampling rate = 8 kHz.
i. Signal Frequency = 3.999 kHz, Sampling rate = 8 kHz.
i. Signal Frequency = 3.999 kHz, Sampling rate = 11.025 kHz.
Sampling
Audacity Demonstration:
Sampling
Cutoff all the frequencies higher than the Nyquist frequency.
Sampling
When the filter is applied the intermediate signal is transformed into
original signal.
Sampling
Low pass filter requires a smooth ramp.
A buffer is needed between the highest frequency and the Nyquist
frequncy.
Sampling
This gives us a clue regarding the amplitude modulation of the signal
created by Signal Frequency = 3.999 kHz, Sampling rate = 8 kHz..
Sampling
This is in direct violation of sampling theorem which requires to be no
frequency above Nyquist frequency.
Sampling
This results in folding of the frequencies above the Nyquist back into the
original spectrum due to a phenomenon call Aliasing.
Sampling
Sampling
Aliasing
According to the sampling theorem, a continuous-time signal with
frequencies no higher than 𝑓𝑚𝑎𝑥 (Hz) can be reconstructed exactly from
its samples if the samples are taken at a rate greater than 2𝑓𝑚𝑎𝑥 , i.e., 𝑓𝑠 ≥
2𝑓𝑚𝑎𝑥 .
Violation of the sampling theorem results in an aliasing, which can be
visualized in both the time and frequency domains.
Consider a signal made up of sinusoids: 𝑥 𝑡 = 𝑎 cos 2𝜋𝑓𝑡 + 𝜑 .
Substituting 𝑓 = 𝑓0 + 𝑘𝑓𝑠 , where 𝑘 is an integer
𝑥 𝑡 = 𝑎 cos 2𝜋 𝑓0 + 𝑘𝑓𝑠 𝑡 + 𝜑
Aliasing
We sample this signal at 𝑇𝑠 intervals
𝑥 𝑛 = 𝑥 𝑛𝑇𝑠 = 𝑎 cos 2𝜋𝑓0 𝑛𝑇𝑠 + 2𝜋𝑘𝑓𝑠 𝑛𝑇𝑠 + 𝜑
Both 𝑘 and 𝑛 are integers, so their product is also an integer. Also, 𝑓𝑠 𝑇𝑠 =
1. Hence,
𝑥 𝑛 = 𝑥 𝑛𝑇𝑠 = 𝑎 cos 2𝜋𝑓0 𝑛𝑇𝑠 + 𝜑
When under sampled, a signal of frequency 𝑓 = 𝑓0 + 𝑘𝑓𝑠 will look like a
signal of frequency 𝑓0 .
Aliasing
Aliasing
Aliasing
Aliasing
Aliasing
Example: Assume, 𝑓𝑠 = 500 samples/seconds, 𝑓 = 600 Hz.
Aliasing
Example: Assume, 𝑓𝑠 = 100 samples/seconds, 𝑓 = 90 Hz.
Aliasing
Aliasing
Aliasing
The continuous signal 𝑓 𝑥 is sampled by multiplying it by an impulse
train (Shah function – sum of delta functions).
Aliasing
The Fourier transform of the Shah function is also a Shah function.
𝑢
Aliasing
Multiplication in spatial domain is equivalent to convolution in Fourier
domain.
𝑢
Aliasing
If a train of delta functions 𝑆 𝑢 is convolved with a function 𝐹 𝑢 ,
multiple copies of 𝐹 𝑢 is obtained.
Aliasing
Can we recover 𝑓 𝑥 from 𝑓𝑠 𝑥 ? In other words, can we recover 𝐹 𝑢
from 𝐹𝑠 𝑢 ?
Aliasing
If 𝑢𝑚𝑎𝑥 > 1Τ 2𝑥0 , then these copies are going to overlap resulting in
Aliasing.
Aliasing
Quantization
Measurement of signal amplitude at discrete time intervals.
Quantization
Each point on the amplitude scale can have an infinite resolution with an
unending number of digits.
Quantization
We need to decide the maximum resolution of the digital signal. This
provides the accuracy of measurements.
Quantization
Accuracy drops for low resolution.
Quantization
For high resolution, the accuracy becomes more accurate.
Quantization
The sampling interval along the amplitude axis determines the maximum
dynamic range that the digital signal can represent.
Dynamic range is the range between the highest and the lowest amplitude
moments in the sound.
Quantization
Resolution impacts the amount of noise present in the digitized signal.
This noise affects the overall dynamics range that is available.
Quantization
Signal is sampled along x-axis Measurements stick to one of the
eight discrete levels of magnitude
The eight levels are regarded as the resolution of the digitization process.
Quantization
This process of mapping the analog signal values to a limited range of
discrete values is called quantization.
This is a three bit resolution - the resolution is quite poor.
Quantization
The difference between the original analog signal value and the discrete
digital value - quantization error.
This error causes unintended noise to permeate into the digital signal.
Dynamic range of the digitized signal is just the difference between the
highest discrete point to the amplitude of the quantization error itself.