information theoryhamada/it/l08-it.pdf4. fano code. the fano code is a technique for constructing...
TRANSCRIPT
![Page 1: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/1.jpg)
Information Theory
Mohamed Hamada
Software Engineering LabThe University of Aizu
Email: [email protected]: http://www.u-aizu.ac.jp/~hamada
![Page 2: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/2.jpg)
Today’s Topics
• Source Coding Techniques• Fano Code• Coding Examples• Shannon Code• Code Comparison
1
![Page 3: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/3.jpg)
Channel
Source Coding Techniques
InformationSource
User of Information
Source Encoder
Channel Encoder
Modulator
Source Decoder
Channel Decoder
De-Modulator
1. Huffman Code.
2. Two-pass Huffman Code.
4. Fano code.
5. Shannon Code.
6. Arithmetic Code.
3. Lemple-Ziv Code.
2
Sender Receiver
![Page 4: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/4.jpg)
Source Coding Techniques
1. Huffman Code.
2. Two-pass Huffman Code.
4. Fano code.
5. Shannon Code.
6. Arithmetic Code.
3. Lemple-Ziv Code.
3
![Page 5: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/5.jpg)
Source Coding Techniques
1. Huffman Code.
2. Two-path Huffman Code.
4. Fano Code.
5. Shannon Code.
6. Arithmetic Code.
3. Lemple-Ziv Code.
4
![Page 6: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/6.jpg)
4. Fano Code.
The Fano code is a technique for constructing a prefix code
It is suboptimal in the sense that it does not achieve the lowest possible expected code word length like Huffman coding.
However unlike Huffman coding, it does guarantee that all code word lengths are within one bit of their theoretical ideal log(1/P(x)).
5
Fano coding is used in the IMPLODE compression method, which is part of the ZIP file format.
(Also called Shannon-Fano code)
![Page 7: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/7.jpg)
4. Fano Code.
The Fano code is performed as follows:
1. arrange the information source symbols in order of decreasing probability
2. divide the symbols into two equally probable groups, as possible as you can
3. each group receives one of the binary symbols (i.e. 0 or 1) as the first symbol
4. repeat steps 2 and 3 per group as many times as this is possible.
5. stop when no more groups to divide
6
![Page 8: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/8.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
1. arrange the information source symbols in order of decreasing probability
7
![Page 9: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/9.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
2. divide the symbols into two equally probable groups, as possible as you can
8
![Page 10: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/10.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
3. each group receives one of the binary symbols (i.e. 0 or 1) as the first symbol
00
111
11
111
9
![Page 11: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/11.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
4. repeat steps 2 and 3 per group as many times as this is possible.
00
111
11
111
10
![Page 12: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/12.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
00
111
11
111
2. divide the symbols into two equally probable groups, as possible as you can
11
![Page 13: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/13.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
00
111
11
111
3. each group receives one of the binary symbols (i.e. 0 or 1) as the first symbol
01
12
![Page 14: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/14.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
00
111
11
111
01
13
![Page 15: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/15.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
00
111
11
111
01
2. divide the symbols into two equally probable groups, as possible as you can
14
![Page 16: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/16.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
00
111
11
111
01
3. each group receives one of the binary symbols (i.e. 0 or 1) as the first symbol
001
11
111
15
![Page 17: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/17.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
00
111
11
111
01
001
11
111
4. repeat steps 2 and 3 per group as many times as this is possible.
16
![Page 18: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/18.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
00
111
11
111
01
001
11
111
2. divide the symbols into two equally probable groups, as possible as you can
17
![Page 19: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/19.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
00
111
11
111
01
001
11
111
3. each group receives one of the binary symbols (i.e. 0 or 1) as the first symbol
01
18
![Page 20: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/20.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
00
111
11
111
01
001
11
111
01
19
![Page 21: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/21.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
00
111
11
111
01
001
11
111
01
2. divide the symbols into two equally probable groups, as possible as you can
20
![Page 22: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/22.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
00
111
11
111
01
001
11
111
01
3. each group receives one of the binary symbols (i.e. 0 or 1) as the first symbol
0
01
111
21
![Page 23: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/23.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
00
111
11
111
01
001
11
111
010
01
111
2. divide the symbols into two equally probable groups, as possible as you can
22
![Page 24: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/24.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
00
111
11
111
01
001
11
111
010
01
111
3. each group receives one of the binary symbols (i.e. 0 or 1) as the first symbol
0
1
23
![Page 25: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/25.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
00
111
11
111
01
001
11
111
010
01
111
0
1
2. divide the symbols into two equally probable groups, as possible as you can
24
![Page 26: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/26.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
00
111
11
111
01
001
11
111
010
01
111
0
1
3. each group receives one of the binary symbols (i.e. 0 or 1) as the first symbol
0
011
25
![Page 27: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/27.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
00
111
11
111
01
001
11
111
010
01
111
0
10
011
2. divide the symbols into two equally probable groups, as possible as you can
26
![Page 28: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/28.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
00
111
11
111
01
001
11
111
010
01
111
0
10
011
3. each group receives one of the binary symbols (i.e. 0 or 1) as the first symbol
0
1
27
![Page 29: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/29.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
00
111
11
111
01
001
11
111
010
01
111
0
10
011
0
1
2. divide the symbols into two equally probable groups, as possible as you can
28
![Page 30: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/30.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
00
111
11
111
01
001
11
111
010
01
111
0
10
011
0
1
3. each group receives one of the binary symbols (i.e. 0 or 1) as the first symbol
01
29
![Page 31: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/31.jpg)
Example 1:
4. Fano Code.
Symbol Probability Fano CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
00
111
11
111
01
001
11
111
010
01
111
0
10
011
0
1
5. stop when no more groups to divide
01
30
![Page 32: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/32.jpg)
4. Fano Code.
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.
Symbol Probability Fano Code
T 1/3
U 1/3
V 1/9
W 1/9
X 1/9
Example 2:
1
0
00
0
1
1 1
1 1 1
0
32
![Page 33: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/33.jpg)
Example 3:
4. Fano Code.
Symbol Probability Fano CodeA 0.39 00
B 0.18 01
C 0.15 10
D 0.15 110
E 0.13 111
31
0
0 1
0 1 0 1
1
0 1
0 1 01
0 1
Tree form:
![Page 34: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/34.jpg)
Source Coding Techniques
1. Huffman Code.
2. Two-path Huffman Code.
4. Fano Code.
5. Shannon Code.
6. Arithmetic Code.
3. Lemple-Ziv Code.
33
![Page 35: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/35.jpg)
5. Shannon Code.
The Shannon code is the coding method used to proveShannon's noiseless coding theorem
It constructs a uniquely decodable code
It is suboptimal in the sense that it does not achieve the lowest possible expected code word length like Huffman coding.
34
![Page 36: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/36.jpg)
5. Shannon Code.
The Shannon code is performed as follows:
1. calculate a series of cumulative probabilities
k
iik pq
1, k=1,2,…,n
2. calculate the code length for each symbol using log(1\pi )≤ li < log (1\pi )+ 1
3. write qk in the form c1 2-1 + c2 2-2 + … + cli 2-li where each ci is either 0 or 1
35
![Page 37: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/37.jpg)
Example 4:
Symbol Probability qk Length li Shannon CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
1. calculate a series of cumulative probabilities
5. Shannon Code.
0+
1/4+
1/2+5/8+
3/4+
13/16+7/8+
29/32+
15/16+
31/3236
![Page 38: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/38.jpg)
Symbol Probability qk Length li Shannon CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
2. calculate the code length for each symbol using
5. Shannon Code.
0
1/41/25/8
3/413/16
7/8
29/3215/1631/32
log(1\pi )≤ li < log (1\pi )+ 1
Example 4:
37
![Page 39: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/39.jpg)
Symbol Probability qk Length li Shannon CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
2. calculate the code length for each symbol using
5. Shannon Code.
0
1/41/25/8
3/413/16
7/8
29/3215/1631/32
log(1\pi )≤ li < log (1\pi )+ 1
Log(1/(1/4)) ≤ l1 < Log(1/(1/4)) + 1
2 ≤ l1 < 2 + 1
Example 4:
38
![Page 40: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/40.jpg)
Symbol Probability qk Length li Shannon CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
2. calculate the code length for each symbol using
5. Shannon Code.
0
1/41/25/8
3/413/16
7/8
29/3215/1631/32
log(1\pi )≤ li < log (1\pi )+ 1
Log(1/(1/4)) ≤ l1 < Log(1/(1/4)) + 12 ≤ l1 < 2 + 1
l1 = 22
Example 4:
39
![Page 41: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/41.jpg)
Symbol Probability qk Length li Shannon CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
2. calculate the code length for each symbol using
5. Shannon Code.
0
1/41/25/8
3/413/16
7/8
29/3215/1631/32
log(1\pi )≤ li < log (1\pi )+ 1
223
3
445
555
Example 4:
40
![Page 42: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/42.jpg)
Symbol Probability qk Length li Shannon CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
5. Shannon Code.
0
1/41/25/8
3/413/16
7/8
29/3215/1631/32
223
3
445
555
3. write qk in the form c1 2-1 + c2 2-2 + … + cli 2-li where each ci is either 0 or 1
Example 3:
41
![Page 43: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/43.jpg)
Symbol Probability qk Length li Shannon CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
5. Shannon Code.
0
1/41/25/8
3/413/16
7/8
29/3215/1631/32
223
3
445
555
3. write qk in the form c1 2-1 + c2 2-2 + … + cli 2-li where each ci is either 0 or 1
qk ≤ c1 2-1 + c2 2-2
Example 4:
42
![Page 44: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/44.jpg)
Symbol Probability qk Length li Shannon CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
5. Shannon Code.
0
1/41/25/8
3/413/16
7/8
29/3215/1631/32
223
3
445
555
3. write qk in the form c1 2-1 + c2 2-2 + … + cli 2-li where each ci is either 0 or 1
qk ≤ c1 2-1 + c2 2-2
0 ≤ c1 2-1 + c2 2-2
Example 4:
43
![Page 45: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/45.jpg)
Symbol Probability qk Length li Shannon CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
5. Shannon Code.
0
1/41/25/8
3/413/16
7/8
29/3215/1631/32
223
3
445
555
3. write qk in the form c1 2-1 + c2 2-2 + … + cli 2-li where each ci is either 0 or 1
qk ≤ c1 2-1 + c2 2-2
0 ≤ c1 2-1 + c2 2-2
c1 = 0, c2 = 0
Example 4:
44
![Page 46: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/46.jpg)
Symbol Probability qk Length li Shannon CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
5. Shannon Code.
0
1/41/25/8
3/413/16
7/8
29/3215/1631/32
223
3
445
555
3. write qk in the form c1 2-1 + c2 2-2 + … + cli 2-li where each ci is either 0 or 1
qk ≤ c1 2-1 + c2 2-2
0 ≤ c1 2-1 + c2 2-2
c1 = 0, c2 = 0
00
Example 4:
45
![Page 47: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/47.jpg)
Symbol Probability qk Length li Shannon CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
5. Shannon Code.
0
1/41/25/8
3/413/16
7/8
29/3215/1631/32
223
3
445
555
3. write qk in the form c1 2-1 + c2 2-2 + … + cli 2-li where each ci is either 0 or 1
0001
100101
11001101
11100111011111011111
Example 4:
46
![Page 48: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/48.jpg)
Symbol Probability qk Length li Shannon CodeA 1/4
B 1/4
C 1/8
D 1/8
E 1/16
F 1/16
G 1/32
H 1/32
I 1/32
J 1/32
5. Shannon Code.
0
1/41/25/8
3/413/16
7/8
29/3215/1631/32
223
3
445
555
0001
100101
11001101
11100111011111011111
Example 4:
47
![Page 49: Information Theoryhamada/IT/L08-IT.pdf4. Fano Code. The Fano code is a technique for constructing a prefix code It is suboptimal in the sense that it does not achieve the lowest](https://reader033.vdocuments.net/reader033/viewer/2022052718/5f04f40d7e708231d4108774/html5/thumbnails/49.jpg)
Example
Symbol Probability qk Length li Shannon Code Fano code
W 0.4 0 2 00 0
X 0.3 0.4 2 01 10
Y 0.2 0.7 3 101 110
Z 0.1 0.9 4 1110 111
5. Shannon Code.
Note that:
from examples 1 and 4 one may conclude that Fanocoding and Shannon coding produce the same code, however this is not true in general as we can see from the following example.
48