Waveform Coding
Waveform Coding
Prof H Xu
Feb. 10, 2025
Text Book
• Communication Systems – Haykin
• Digital Communication– Proakis
Cheating
• No late summary/practical will be accepted.
• Cheating will be not be tolerated and it will be
strongly dealt with. This includes:
– Copying someone else’s Prac codes and report.
– Copying someone’s report/exam answers.
– etc.
UP
• Remind: LB
f ( x)dx = 1
Useful Maths
--Applications of Continuous RVs
• Example of = E[ X ] = − x f ( x)dx and = D[ X ] = − ( x − ) 2 f ( x)dx
2
x
= E[ X ] = x f ( x)dx = a
−
= D[ X ] = ( x − ) 2 f ( x)dx = 2
2
x
−
Useful Maths
--Theory of discrete Random Variable
Discrete time domain:
The mean of X is defined as:
k
= E[ X ] = xi pi
i =1
k
Remind: p
i =1
i =1
Useful Maths
--Application in Digital Communications
1
, −4 ≤ 𝑥 < −1
12
1 −3, −4 ≤ 𝑥 < −2
, −1 ≤ 𝑥 < 1 −1, −2 ≤ 𝑥 < 0
𝑓 𝑥 = 4 𝑚(𝑥) =
1, 0≤𝑥<2
1
,1 ≤ 𝑥 < 4 3, 2≤𝑥<4
12
0, 𝑥 ∉ [−4,4ሿ
Useful Maths
--Application in Digital Communications
𝑋 ∈ 1 + 𝑗; 1 − 𝑗; −1 + 𝑗; −1 − 𝑗
𝑝 𝑥 = 1 + 𝑗 = 𝑝 1 − 𝑗 = 𝑝 −1 + 𝑗 = 𝑝 −1 − 𝑗
= 0.25
4
𝜇= 𝑥𝑖 𝑝𝑖
𝑖=1
= 0.25 1 + 𝑗 + 1 − 𝑗 + −1 + 𝑗 + −1 − 𝑗 =0
4 2
𝜎2 = |𝑥𝑖 − 𝜇 ቚ 𝑝𝑖
𝑖=1
= 0.25 1 + 𝑗 2 + 1−𝑗 2 + −1 + 𝑗 2 + −1 − 𝑗 2 =2
Useful Maths
--Applications in Digital Communications
k e−
E[ X ] = x pi = ( xi = k ) ( pi =k =
2 2
i
2
) = 2 +
i =0 i =0 k!
D[ X ] = E[ X 2 ] − {E[ X ]}2 =
Introduction
→Communication systems are used to transport information
bearing signal from source to destination via a channel.
→The information bearing signal can be:
(a) Analog : analog communication system;
(b) Digital : digital communication system
Mid-tread Mid-rise
Zero is one of the output Zero is not one of the
levels M is odd output levels M is even
Waveform coding
-- uniform quantizing noise
→Quantizing error consists of the difference between the input
and output signal of the quantizer.
− / 2 input / 2 output = 0
/ 2 input 3 / 2 output =
Waveform coding
-- uniform quantizing noise
Maximum instantaneous value of quantization error is
2
Waveform coding
-- uniform quantizing noise
Can you analyze uniform quantizing noise for mid-rise?
Waveform coding
-- performance of a uniform quantizer
→The performance of a quantizer is measured in terms of the
signal to quantizing error ratio (SQER):
signal _ power
SQER =
Noise _ power
SQER =
E m2 (kTs )
mean square quantizing noise
Waveform coding
-- performance of a uniform quantizer
0 input output = / 2
input 2 output = 3 / 2
3 / 2 − / 2 input 3 / 2 + / 2
⇓
𝑚𝑖 − Δ/2 ≤ 𝑖𝑛𝑝𝑢𝑡 ≤ 𝑚𝑖 + Δ/2
1
For example: Q=16 quantization steps; = step size = 0.5v ; Ts =
2 fM
3 5 7
Threshold: = 0.25 = 0.75 = 1.25 = 1.75
2 2 2 2
Waveform coding
-- Sampling, quantization and coding
1
For example: Q=16 quantization steps; = step size = 0.5v ; Ts =
2 fM
0100 0101
mi + / 2
p(m | i ) =
p(m, i ) p(m)
= Pi = p(m)dm
mi − / 2
Pi Pi
Q
So MSQE = mi + / 2
(m − mi ) 2 p(m | i)dm Pi
m − / 2
i =1 i
Waveform coding
-- Sampling, quantization and coding
Q
MSQE = mi + / 2
(m − mi ) 2 p(m | i)dm Pi
m − / 2
i =1 i
p(m)
p(m | i ) =
Pi
Q
mi + / 2
MSQE = (m − mi ) 2 p(m)dm
mi − / 2
i =1
Waveform coding
-- Linear quantizer with larger Q
If the number of quantizing steps is larger, then p (m) can be
considered constant in a quantization interval.
Q
mi + / 2
So MSQE = (m − mi ) 2 p(m)dm
mi − / 2
i =1
Q Q 3
/2 1
MSQE = p (mi ) x dx = p (mi ) 2
2
i =1
− / 2
i =1 3 2
Q Q
1
p(mi ) =
i =1 i =1 Q
=1
2
MSQE =
12
Waveform coding
-- Linear quantizer with larger Q
Example: the input to a Q-step uniform quantizer has a uniform
pdf over the interval . Calculate the average signal to quantizer
noise power at the output.
Q
mi + / 2
Solution: MSQE = (m − mi ) 2 p(m)dm
mi − / 2
i =1
Q = 2 a p ( m) =
1
2a
1 Q mi + / 2
MSQE =
2a i =1 i
m − / 2
( m − mi ) 2
dm
Q
1 3 Q 3
= =
i =1 2 a 12 2a 12
Q = 2 a
2
=
12
Waveform coding
-- Linear quantizer with larger Q
a 2 1 Q Q 2 2
2
2 1
a
Output signal power: = x dx = = =
−a 2a 3 3 2 12
Or Em (kTs ) = m
Q
mi +
2 2 2
i p(m)dm
mi −
i =1
2
2
−
2
Q 1
= 2 + ( 2 ) + +
m +
2
Q
2a 2
1
= mi2 2 dm
i
3 2 −
2
i =1
m − 2a Q 1
= 2 1 + (2) + +
i
2 2
2a 2
Q
n
12 + 2 2 + + n 2 = (n + 1)(2n + 1)
= mi2 6
i =1 2a Q 2 −1 2
=
12
assume Q is odd
Waveform coding
-- Linear quantizer with larger Q
1 m2
where p(m) = exp − 2
2 2
2
Q = 2N Q is even number.
1 m2
p ( m) =
2 2
exp − 2
2
p(m) is symmetric.
Waveform coding
-- Linear quantizer with larger Q
2 Q / 2−1 mi + / 2 m
MSQE = m − / 2 − − 2 dm
2
( m m ) exp
2 i =0 i 2
i
mi = i + / 2
2 Q / 2−2 (i +1) m m
MSQE = i − − − + − − − 2 dm
2 2
( m / 2 i ) exp dm ( m / 2 i ) exp
2 i =0 2 2
2 [ Q / 2 −1]
signal power 2
SQER = =
MSQE MSQE
Example:
Solution:
(a) Key point: −
f (v)dv = 1
4 1 2 1 1 1
E[e ] = 2 (3 − v) dv + 2
(1 − v) dv + 2 (1 − v) 2 dv
2 2 2
2 12 1 12 0 4
Q
mi +
(d) Signal power is given as E m2 (kTs ) = mi2
2 p(m)dm
mi −
i =1 2
−4 4
Waveform coding
-- Nonuniform quantizing
→Problems with uniform quantization
– Only optimal for uniformly distributed signal
– Real audio signals (speech and music) are more concentrated
near zeros
– Human ear is more sensitive to quantization errors at small
values
law
|x|
log(1 + )
xmax
y = xmax sign( x)
log(1 + )
A law
A| x | 1
1 + log A , 0 | x |
A
y =
1 + log( A | x |) 1
, | x | 1
1 + log A A
Waveform coding
-- Nonuniform quantizing
Waveform coding
-- implementation of μ-law
→(1) Transform the signal using μ-law
| x|
log(1 + )
xmax
y = F ( x) = xmax sign( x)
log(1 + )
→(2) Quantize the transformed value using a uniform
quantizer
→(3) Transform the quantized value back using inverse μ-
law
log(1+ )
xmax | y|
−1
x = F ( y) = 10 xmax
− 1 sign ( y )
Waveform coding
-- implementation of μ-law
Example:
For the following sequence {1.2,-0.2,-0.5,0.4,0.89,1.3…},
Quantize it using a mu-law quantizer in the range of (-1.5,1.5)
with 4 levels, and write the quantized sequence.
Solution: suppose μ=9. we also know x_max=1.5
| x|
log(1 + )
xmax
Step 1: y = F ( x) = xmax sign( x)
log(1 + )
Quantized sequence:
[0.77 - 0.13 - 0.77 0.77 0.77 0.77 ]
Waveform coding
-- performance of a nonuniform quantizer
Recall :
→The performance of a quantizer is measured in terms of the
signal to quantizing error ratio:
SQER =
E m 2 (kTs )
mean square quatizing noise( MSQE)
→For a signal with distribution p (m) , the signal power is
Q
mi +
E m 2 (kTs ) = m 2
i
2
p(m)dm
mi −
i =1 2
Q
mi + / 2
MSQE = (m − mi ) 2 p(m)dm
mi − / 2
i =1
N k =1
where N is the number of samples in the sequence.
x2
SNR =
MSE
N k =1
6
= (1.2 - 0.77) + (,-0.2 + 0.13) + (− 0.5 + 0.77 ) + (0.4 − 0.77 ) + (0.89 − 0.77 ) + (1.3 − 0.77 )
1 2 2 2 2 2 2
x2 =
1
6
(1.2 − x )2 + (- 0.2 − x )2 + (− 0.5 − x )2 + (0.4 − x )2 + (0.89 − x )2 + (1.3 − x )2
x=
1
(1.2 − 0.2 − 0.5 + 0.4 + 0.89 + 1.3)
6
Waveform coding
-- Sampling, quantization and coding
1
For example: Q=16 quantization steps; = step size = 0.5v ; Ts =
2 fM
then E Dr2 m2
1
For 2
That means that the variance of Dr = m(rTs ) − m((r − 1)Ts ) is
less than the variance of sampled signal.
1 1
( Differential PCM; PCM)
2 2
Waveform coding
-- Differential PCM
→the procedure is to encoder the
difference e(rTs ) = m(rTs ) − m[(r − 1)Ts ]
Transmitter
S(i) + e(i) e(i) + q(i) DPCM
Quantiser encoder
-
^
S(i)
+
Predictor
+
Waveform coding
-- Delta Modulation