- 2072 Kartik (CS II) · 2+3 marks
Variable length coding; entropy and fixed code efficiency
Short answer
Variable-length coding assigns shorter codewords to more frequent symbols, reducing average length and approaching entropy. For example, four symbols 0.5,0.25,0.125,0.125 achieve 100% efficiency vs 87.5% fixed. For given probabilities, entropy is 2.3282 bits/symbol; fixed-length code has maximum efficiency 77.61%.
Write down the significance of variable length coding with relevant example. A fixed length source encoder generates six symbols with probabilities {0.2, 0.15, 0.25, 0.05, 0.3, 0.05} and encoded by unique code word. Find entropy and maximum code efficiency.
Significance of variable length coding
In variable-length coding, frequent symbols get short code words and rare symbols get long code words. Its significance:
- The average length becomes smaller than a fixed-length code and can approach the entropy , so bit rate, bandwidth and storage are reduced.
- It uses the source statistics; when probabilities are unequal, fixed-length codes waste bits.
- Prefix (instantaneous) variable-length codes such as Huffman and Shannon–Fano remain uniquely decodable.
Example: four symbols with . Fixed code: 2 bits each, . Variable code 0, 10, 110, 111: bits = , so efficiency rises from 87.5 % to 100 %. (Morse code uses the same idea: "E" is a single dot.)
Numerical
Probabilities (sum = 1).
Entropy:
| Symbol | |||
|---|---|---|---|
| x1 | 0.2 | 2.3219 | 0.4644 |
| x2 | 0.15 | 2.7370 | 0.4105 |
| x3 | 0.25 | 2.0000 | 0.5000 |
| x4 | 0.05 | 4.3219 | 0.2161 |
| x5 | 0.3 | 1.7370 | 0.5211 |
| x6 | 0.05 | 4.3219 | 0.2161 |
| Total | 1 | 2.3282 |
Fixed-length code: 6 symbols need bits each, so bits/symbol.
Maximum code efficiency of this fixed-length encoder:
(Redundancy = 22.39 %.) A variable-length code, e.g. Huffman with bits, would raise the efficiency to .
(If "maximum efficiency" is read instead as the source efficiency relative to the maximum entropy bits/symbol, it is .)
Answer: bits/symbol; maximum efficiency of the fixed-length code = 77.61 %.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Importance of source coding; Shannon-Fano vs fixed length (seven symbols) · Communication Systems, chapter 6
- Source coding; Huffman for five symbols (0.3, 0.25, 0.2, 0.15, 0.1) · Communication Systems, chapter 6
- Importance of source coding; fixed vs Shannon-Fano (five symbols) · Communication Systems, chapter 6
- Importance of source coding; Huffman for eight symbols at 1000 symbols/s · Communication Systems, chapter 6
- Importance of source coding; Shannon-Fano vs BCD (four symbols) · Communication Systems, chapter 6
- Source vs channel coding; Huffman for five symbols · Communication Systems, chapter 6
- Source coding; fixed vs variable length codes · Data Communication, chapter 8
- Huffman code for symbols A to E (0.4, 0.3, ...) · Data Communication, chapter 8
- Shannon-Fano code for six symbols · Data Communication, chapter 8
- Shannon-Fano code for eight symbols · Data Communication, chapter 8