Professional Documents
Culture Documents
Revision of Lecture 1
pi log2 (bits/symbol)
H= pi
Information rate i=1
R = Rs · H (bits/s)
11
Maximum Entropy for q-ary Source
Σ
q pi log2 pi when it reaches maximum?
• Entropy of a q-ary source: H =Σ− i=1
q
• Maximisation under the constraint = 1 is based on the Lagrangian
p
i=1
X
q i !
L= +λ· 1 Xqpi
!
i=1 − i=1
and yields −pi log2 pi
∂L
∂p = − log − log2 e − λ = 0
2
i
pi
q
• Since log2 pi = −(log2 e + λ) is independent of i, i.e. constant, and Σ i=1 pi = 1,
0.8
Entropy H(p)
0.6
0.4
0.2
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
symbol probability p
• Source entropy is maximum for equiprobable symbols, p1 = p2 = 0.5
Efficient Source Coding
• We are considering lossless source coding, i.e. when we convert symbols into bit
streams (codewords), we do not throw away any “information”
• Efficient channel use requires efficient source encoding, and coding efficiency:
– Coding each symbol into log2 q-bits codeword is efficient, since coding efficiency
H log2 q = 100%
CE =
= log q
log2 q 2
• For equiprobable case, H = log2 8 = 3 bits/symbol, and coding each symbol with 3-bits
codeword achieves coding efficiency of 100%
• For non-equiprobable case,
H = −0.27 log2 0.27 − 0.20 log2 0.20 − 0.17 log2 0.17 − 0.16 log2 0.16
CE = 2.6906/3 = 89.69%
ELEC3028 Digital Transmission – Overview & Information Theory S Chen
Shannon-Fano Coding
Shannon-Fano source encoding follows the steps
2. Divide symbols into subgroups such that the subgroup’s probabilities (i.e.
information contests) are as close as possible
can be two symbols as a subgroup if there are two close probabilities (i.e. information contests), can
also be only one symbol as a subgroup if none of the probabilities are close
3. Allocating codewords: assign bit 0 to top subgroup and bit 1 to bottom subgroup
4. Iterate steps 2 and 3 as long as there is more than one symbol in any subgroup
20
ELEC3028 Digital Transmission – Overview & Information Theory S Chen
• Less probable symbols are coded by longer code words, while higher probable
symbols are assigned short codes
Assign number of bits to a symbol as close as possible to its information content,
and no codeword forms a prefix for any other codeword
21
Shannon-Fano Coding Example (continue)
Coding efficiency is 100% (Coding efficiency is 66% if codewords of equal length of 3-bits are used)
Huffman Coding
2. Merge the two least probable symbols (or subgroups) into one subgroup
3. Assign ’0’ and ’1’ to the higher and less probable branches, respectively, in the
subgroup
4. If there is more than one symbol (or subgroup) left, return to step 2
5. Extract the Huffman code words from the different branches (bottom-up)
Huffman Coding Example
• Average code word length with Huffman coding for the given example is also 2.73 (bits/symbol),
and coding efficiency is also 98.56%
• Try Huffman coding for 2nd example and compare with result of Shannon-Fano coding
Shannon-Fano and Huffman Source Encoding Summary
• Huffman coding gives a different code word assignment to Shannon-Fano coding; the
coding efficiency is however nearly identical
∂L ∂ log2 pi
= − log2 − p
∂p −
pi i λ
Note ′ i ∂pi
′ V
1 ∂L
(loga V ) = and = log2 e = − log2 pi − log2 e − λ
V loge a loge ∂p
2
i