Professional Documents
Culture Documents
Source Coding
Dr. Mohamed A. Abdelhamed
Department of Communication and Computer Eng.
Higher Institute of Engineering, El-Shorouk Academy.
Academic year (2018-2019)
Contacts:
WhatsApp: +201002323525
E-mail: m.abdelhamed@sha.edu.eg
mohabdelhamed@yahoo.com
2.1 SOURCE ENTROPY
The entropy of a source is defined as the average
amount of information per symbol (bit/symbol) for
the message generated by the source (X), that is
2
2.1 SOURCE ENTROPY
3
2.1 SOURCE ENTROPY
Generally, H ( X ) logL for any given set of source
symbol probabilities and the equality is achieved when
the symbols are equiprobable.
Example:
Consider a discrete memoryless source that emits two
symbols (or letters) x1 and x2 with probabilities q and 1-q,
respectively. Find and sketch the entropy of this source as
a function of q. Hint: This source can be a binary source
that emits the symbols 0 and 1 with probabilities q and 1-
q, respectively.
4
2.1 SOURCE ENTROPY
Solution:
5
2.1 SOURCE ENTROPY
6
2.1 SOURCE ENTROPY
7
2.1 SOURCE ENTROPY
(Extended source)
8
2.1 SOURCE ENTROPY
(Extended source)
H X k kH ( X )
9
2.1 SOURCE ENTROPY
(Extended source)
10
2.1 SOURCE ENTROPY
(Extended source)
11
2.1 SOURCE ENTROPY
(Extended source)
12
2.2 Coding for Discrete Memoryless Sources (DMS)
stream of bits
DMS Source
encoder Stream of bits
Correspond to
Figure 2.2 Source Encoding stream of symbols
or message
13
2.2 Coding for Discrete Memoryless Sources (DMS)
14
2.2 Coding for Discrete Memoryless Sources (DMS)
equality is achieved
when the symbols
are equiprobable
L Probability of occurrence
Average code word R Pn
i i
of symbol
length i 1
Code word length
of symbol 15
2.2 Coding for Discrete Memoryless Sources (DMS)
Rmin H ( x)
1
R R
16
2.2 Coding for Discrete Memoryless Sources (DMS)
Code efficiency
17
2.2.1 Fixed-Length Code Words
R log 2 L 1
Where:
x : denotes the largest integer less than x.
R: Number of bits/symbol
L: Number of symbol
18
2.2.1 Fixed-Length Code Words
H ( x)
R
log 2 L
R
R log 2 L
1
19
2.2.1 Fixed-Length Code Words
Problem:
Find the code efficiency for the fixed-length word
encoder assuming the following DMSs:
(a) 8 equiprobable symbols
(b) 10 equiprobable symbols
(c) 100 equiprobable symbols
(d) 4 symbols with probabilities 0.5, 0.25, 0.125, 0.125
20
2.2.1 Fixed-Length Code Words
21
2.2.1 Fixed-Length Code Words
2 L
N k or N k log 2 L
Hence, the minimum value of N is given by
N k log 2 L 1
For extended source 22
2.2.1 Fixed-Length Code Words
2 L
N k or N k log 2 L
Hence, the minimum value of N is given by
N k log 2 L 1
For extended source
23
2.2.1 Fixed-Length Code Words
25
2.2.2 Variable Length Code Words
Example:
consider a DMS with output symbols x1, x2, x3 and x4
with probabilities 1/2, 1/4, 1/8, and 1/8, respectively.
In code I,
the first symbol corresponding to 0 0 is x2. However, the
next four bits are not uniquely decodable since they may
be decoded as x4x3 or x1x2x1.
Perhaps, the ambiguity can be resolved by waiting for
additional bits, but such a decoding delay is highly
undesirable.
The tree structure of Code II and code III are shown in
Figure 2.3. Code II is uniquely decodable but not
simultaneously decodable (delay in decoding process
which is undesired).
28
2.2.2 Variable Length Code Words
30
Kraft Inequality
32
Huffman Coding Algorithm
33
Huffman Coding Algorithm
34
Huffman Coding Algorithm
35
Huffman Coding Algorithm
Example:
Consider a DMS with five possible symbols having the
probabilities 0.4, 0.2, 0.2, 0.1 and 0.1. Use Huffman
encoding algorithm to find the code word for each symbol
and the code efficiency.
Solution
The following table shows the complete steps of Huffman
encoding for the given source.
36
Huffman Coding Algorithm
37
Huffman Coding Algorithm
L
R ni Pi (2 0.4 2 0.2 2 0.2 3 0.1 3 0.1) = 2.2 bits
i 1
H ( x)
= 0.9645
R
1 = 0.0355
39
Huffman Coding Algorithm
40
Huffman Coding Algorithm
L
2 (ni R)2 Pi
i 1
41
Huffman Coding Algorithm
Report:
Consider a DMS that produces three symbols x1, x2 and x3
with probabilities 0.45, 0.35, and 0.2, respectively. Find
the entropy, the code words, and the encoding efficiency
in both cases of single symbol encoding and two symbol
encoding (second-order extension code).
42
Fano Coding Algorithm
Example:
44
Fano Coding Algorithm
Note that:
If it was not possible to divide precisely the
probabilities into equally probable groups, we should
try to make the division as good as possible, as we can
see from the following example.
45
Huffman vs. Fano coding
46
MUTUAL INFORMATION IN DMCs
47
MUTUAL INFORMATION IN DMCs
49
MUTUAL INFORMATION IN DMCs
P xi , y j P y j , xi P X xi ,Y y j
P Y y j X xi P X xi
P X xi Y y j P Y y j
P y j xi P xi P xi y j P y j
50
MUTUAL INFORMATION IN DMCs
51
MUTUAL INFORMATION IN DMCs
P xi y j
P xi , y j
P y j xi P xi
P y j P y j
P y j xi P xi P y j xi P xi
q q
P xi , y j P y j xi P xi
i 1 i 1
52
MUTUAL INFORMATION IN DMCs
q
1
H X y j P xi y j log
i 1
P xi y j bits/symbol
53
MUTUAL INFORMATION IN DMCs
Q
H X Y H X yj P yj
j 1
P xi
Q q
1
y j P y j log 2
j 1 i 1 P xi y j
Q q
P xi , y j log2 P
1
j 1 i 1 xi y j
54
MUTUAL INFORMATION IN DMCs
55
MUTUAL INFORMATION IN DMCs
I X ;Y H X H X Y
H Y H Y X
H X H X Y H Y H Y X
56
Relationships between entropies
57
Relationships between entropies
58
?
59