Entropy-Optimal Code
A code is entropy-optimal for a distribution p if its expected code length equals the entropy H(p), which holds exactly when every codeword length is L_i = log₂(1/p_i); by Shannon's source coding theorem a prefix-free code with expected length below H + 1 always exists.
Formula#
The theorem’s code uses lengths , with expected length .
Properties#
- Lower bound. Among codes with (Kraft equality, see Prefix-Free Code), . Proof (DBIS Exam WS1920 (not published), Task 2.2): minimize subject to with the Lagrangian . Setting gives . Summing over gives , so , i.e. , and then (the exam allows assuming there are no saddle points).
- Exactly iff every is a negative power of 2 (), because only then , i.e. no rounding (DBIS Exam WS1819 (not published), Task 2.2).
- Standard proof technique that a given code is entropy-optimal for some distribution: set , check , and compute .
- Uniform distribution over symbols: the fixed-length -bit code is entropy-optimal.
Example#
Code , , , , (DBIS Exam WS2122 (not published), Task 2.3): choose , i.e. , (sum ). Then .
Sources#
- DBIS Exam WS1314 (not published) Task 1.4, DBIS Exam WS1516 (not published) Task 2.4, DBIS Exam WS1718 (not published) Tasks 2.3–2.4, DBIS Exam WS1819 (not published) Tasks 2.1–2.2, DBIS Exam WS1920 (not published) Tasks 2.1–2.2, DBIS Exam WS2122 (not published) Task 2.3
- Not lectured in WS 25/26.