Sampling and Quantization
Sampling and Quantization
Sampling
Prof. Bikash Kumar Dey
Contents
1. Introduction
Sampling:
Why digitize analog sources: Read Sec. 7.1, 7.2 for a detailed account.
Mathematical representation in time domain:
Let us consider an analog signal g(t). The sampling impulse train is represented by
∞
X
h(t) = δ(t − nTs ) (1)
n=−∞
where Ts is the sampling interval. Its reciprocal fs = 1/Ts is called the sampling frequency. The sampled
version of g(t) is then given by
gδ (t) = h(t)g(t)
X∞
= g(nTs )δ(t − nTs )
n=−∞
Frequency domain:
We can also express the spectrum alternatively, by noting that the Fourier transform of h(t) is
∞
X
H(f ) = fs δ(f − nfs ). (2)
n=−∞
Hence
Gδ (f ) = G(f ) ∗ H(f )
X∞
= fs G(f − nfs )
n=−∞
X
= fs G(f ) + fs G(f − nfs ) (3)
n̸=0
fs
There is no overlap between the terms in (3) if g(t) has a bandwidth B ≤ 2
. Then
1
G(f ) = Gδ (f ), −fs /2 < f < fs /2 (4)
fs
1 f
= Gδ (f ) · rect (5)
fs fs
We can then recover g(t) from gδ (t), by passing it through a filter with low-pass frequency response
band-limitted to [−fs /2, fs /2]. In other words,
g(t) = gδ (t) ∗ sinc (fs t)
X∞
= g(nTs )δ(t − nTs ) ∗ sinc (fs t)
n=−∞
X
= g(nTs )sinc (fs (t − nTs )) (6)
n
This gives the optimum interpolation formula to recover the original analog signal from its sampled
version.
If fs < 2B, then the terms in (3) overlap in frequency domain and the term G(f ) can not be separated
from the sum. This is called aliasing.
To avoid aliasing, a low-pass filter is used with passband [−fs /2, fs /2] before sampling. This filter is
called anti-aliasing filter. To avoid stringent requirement on the interpolation filter (sinc requires a non-
causal filter, and it is also infinite length, so impractical), in practice, the sampling frequency is taken to be
significantly higher than the Nyquist rate 2B. Then the interpolation filter is allowed to have a transition
band, and such a filter is easier to design.
−fs −B 0 B fs
For a short pulse p(t), the spectrum P (f ) is very wide, and it passes (when multiplied to the terms
above) many copies of G(f ). If Nyquist criterion is satisfied, then the terms do not overlap, and the term
corresponding to k = 0 can be recovered by passing through a low-pass reconstruction filter. However, an
ideal low-pass filter gives G(f )P (f ) as the output. This results in some distortion amounting to smoothing
(g(t) ∗ p(t)) in time domain. This can be thought of as the view of the signal through a non-zero aparture.
Thus this distortion is called the aperture effect. An equalizer filter can be used at the end to equalize
this effect.
ϕ(t) Reconstruction 1
g(t)
Equalizer H(f )
filter
where kp is the sensitivity constant. We need the different terms above to be non-overlapping. A sufficient
condition fo that is
Ts
p(t) = 0 for |t| > − kp |m(t)|max ,
2
which in turn requires that
Ts
kp |m(t)|max <
2
Pulse width modulation (PWM)
Here the width of a pulse is changed according to the message signal.
X 1
ϕ(t) = p (t − nTs )
n
k 0 + kw m(t)
where An is an amplitude level determined by the n-th chunk of k bits of the message. Such a modulation
scheme is known as M -ary PAM, where M = 2k (e.g. 16-ary PAM, or in short 16-PAM).
4
where τn is one of the M = 2k values determined by the n-th chunk of k-bits of message.
Digital pulse width modulated signal has the form
X 1
ϕ(t) = p (t − nTs )
n
w n
where wn is one of the M = 2k values determined by the n-th chunk of k-bits of message.
Quantization
Uniform quantization
Suppose a message signal takes the values between [mmax , −mmax ]. This is divided into equal L = 2R
intervals of length ∆ = 2mLmax . Each interval is assigned a binary code string to represent. The mid-point
of each interval is taken as the reconstruction value.
For a message value m, suppose its reconstructed value is represented by m̂. The difference
Q = m − m̂
is called the quantization noise.
If ∆ is small, then we can assume that the quantization noise is uniformly distributed in [−∆/2, ∆/2].
So, the quantization noise power is given by
Z ∆
2
2
σQ = q 2 fQ (q)dq
∆
2
Z ∆
1 2
= q 2 dq
∆ ∆
2
∆
1 ∆3 2
= ·
∆ 3 −∆
2
∆2
=
12
where Sk are the decision/quantization regions, mk are the reconstruction points, fM is the density of m,
and d(·, ·) is the squared error distortion function.
A. Optimum mk for given Sk : We need to minimize
Z
Dk (mk ) = (m − mk )2 fM (m)dm
m∈Sk
This is the centroid of Sk w.r.t. the conditional distribution fM (m|Sk ), or the conditional mean of M in
Sk .
B Optimum Sk for given mk : Clearly, the optimum Sk is given by
Sk,opt = {m|(m − mk )2 ≤ (m − kj )2 ∀j ̸= k}
= {m||m − mk | ≤ |m − mj | ∀j ̸= k}
That is, each point is put in the region of mk if mk is the nearest reconstruction point from that point.
Thus the quantization boundaries or thresholds are the midpoints between the successive reconstruction
points.
Lloyd-Max algorithm: A suboptimal algorithm as described below.
1) Take initial guess of mk ; k = 1, 2, · · · , L.
2) Iterate on steps B and A till an exit condition (e.g. a fixed number of iterations or sufficiently small
average distortion) is satisfied.
3) To avoid a bad local minimum, sometimes, the above two steps are run multiple times with different
initial values and the best solution obtained is taken.
Vector quantization Several samples (X1 , X2 , · · · , Xn ) are taken and quantized as a vector in Rn .
Scalar quantization can be thought as a special case with rectangular decision regions.