Beruflich Dokumente
Kultur Dokumente
Data Compression
Peng-Hua Wang
x 6= x′ ⇒ C(x) 6= C(x′ )
1 0 0 10 0
2 0 010 00 10
3 0 01 11 110
4 0 10 110 111
Problem Given the source pmf pP1 , p2 , . . . pm , find the code length
l1 , l2 , . . . , lm such that the expected code length is minimized
X
L= pi li
with constraint
X
D−li ≤ 1.
■ l1 , l2 , . . . , lm are integers.
■ We first relax the original integer programming problem. The
restriction of integer length is relaxed to real number.
■ Solve by Lagrange multipliers.
X X
−li
∂J
J= pi li + λ D , = pi − λD−li ln D
∂li
∂J −li pi
=0⇒D =
∂li λ ln D
X
−li 1
D ≤1⇒λ= ⇒ pi = D−li
ln D
⇒ optimal code length li∗ = − logD pi
Proof.
X X
L − HD (X) = pi l i + pi logD pi
X −li
X
=− pi logD D + pi logD pi
= D(p||q) ≥ 0
where qi = D−li .
D−li ≤ 1 may not be a valid distribution.
P
WRONG!! Because
Proof.
X X
L − HD (X) = pi li + pi logD pi
X X
−li
=− pi logD D + pi logD pi
−lj −li
P
Let c = j D , ri = D /c,
X pi
L − HD (X) = pi logD − logD c
ri
1
= D(p||r) + logD ≥ 0
c
since D(p||r) ≥ 0 and c ≤ 1 by Kraft inequality. L ≤ HD (X) with
equality iff pi = D −li . That is, iff − logD pi is an integer for all i.
L∗ ≤ L < HD (X) + 1.
On another hand, from Theorem 5.3.1,
L∗ ≥ HD (X).
Therefore,
HD (X) ≤ L∗ < HD (X) + 1.
H(X1 , X2 , . . . , Xn ) ≤ E[l(X1 , X2 , . . . , Xn )]
< H(X1 , X2 , . . . , Xn ) + 1
H(X1 , X2 , . . . , Xn ) ≤ E[l(X1 , X2 , . . . , Xn )]
< H(X1 , X2 , . . . , Xn ) + 1
L∗n → H(X )
where H(X ) is the entropy rate of the random process.
Theorem 5.4.3 (Wrong Code) The expected length under p(x) of the
1
code assignment l(x) = ⌈log q(x) ⌉ satisfies
Proof. Consider
!k
X XX X
D −l(x)
= ··· D−l(x1 ) D−l(x2 ) · · · D−l(xk )
x x1 x2 xk
−l(xk )
X −l(x1 ) −l(x2 ) −l(xk )
X
= D D ···D = D
x1 ,...,xk ∈X k xk ∈X k
where lmax is the maximum codeword length and a(m) is the number of
source sequences mapping into codewords of length m.
Therefore,
!k klmax klmax
X X X
D−l(x) = a(m)D−m ≤ Dm D−m = klmax
x m=1 m=1
or
X
D−lj ≤ (klmax )1/k
j
p1 → w1 , p2 → w2 , . . . , pK−1 + pK → wK−1 ,