Optimal Source Code: L L L L P L
Optimal Source Code: L L L L P L
P
We wish to minimize L = pili subject to the
constraint that l1, l2, . . . , lm are integers
P −l
and r i ≤ 1.
li = dlogr p1 e
i
i=1
Ln
In the limit, lim = Hr (S)
n→∞ n
and Hr (S n) ≤ Hr (S¯n) ≤ Ln
Hr (S)+ Hr (S̄)−H
n
r (S)
≤ Ln < H (S)+ Hr (S̄)−Hr (S)+1
n r n
Ln
Here also lim can be made as close to
n→∞ n
Hr (S) as possible.
Shannon Fano coding scheme
27
At every level, if the two symbols having small-
est probabilities are collapsed into a compound
symbol and we go on constructing the coding
tree as a heap, we get the optimal code.
q
1 2 1 P 2
X
q ei = 0 and var(ei) = σ = q ei
i=1
Hence, L0 = 1q lip0i = L + 1q
P P
liei
1 P
We should examine q liei to get a better feel
of how the length is affected by noise.
1 1 1
L = q liei − λ q ei − µ( q ei − σ 2)
P P 2
28
∂L = 1 (l − λ − 2µe ) = 0
∂ei q i i
On summing over i, 1q i li − λ = 0
P
gives λ = 1q i li.
P
∂L = 0 gives
ei ∂e
i
P
1 2µ 2 ) = 0 to get µ = ei l i
−
P P
q l i ei q (ei 2qσ 2
.
∂L = 0 gives
Now, putting λ and µ in li ∂e
i
1 P l2 − λ 1 P l − 2µ 1 P(e l ) = 0
q i q i q i i
1 P 2 1 P 2 1
Then, we can write ( q eili) = ( q li −( q li)2)σ 2
P
1
i.e. ( q eili)2 = Var (li) Var (ei)
P
29