Attic › Mathematics › Shannon's source coding theorem
Shannon's source coding theorem defines the exact limit of lossless data compression
Shannon's source coding theorem gives the mathematical limit for how much a file can be compressed without losing any data. Proved by Claude Shannon in 1948, the theorem is the foundation of information theory. It states that, as the length of the data stream tends to infinity, the average number of bits per symbol cannot be less than the entropy of that source without information almost certainly being lost, yet it can be brought arbitrarily close to it.
A data source—such as English text or a digital image—produces a stream of symbols. If each symbol occurs independently and with a fixed probability (making them independent and identically distributed random variables), we can compress the data by giving short binary codes to common symbols and long binary codes to rare ones. For example, in Morse code, the common letter E is a single dot, while the rare letter Q is four symbols long.
To find the absolute limit of this method, Shannon defined entropy (written as H). A symbol with probability p gives −log₂(p) bits of information: rare symbols have a small p and give many bits of information, while common symbols have a large p and give very few. The entropy H is the average information per symbol across all n possible symbols:
H = −∑ pᵢ log₂(pᵢ)
Suppose a source outputs four symbols with these probabilities:
1. A occurs ½ of the time (code: 0, length 1)
2. B occurs ¼ of the time (code: 10, length 2)
3. C occurs ⅛ of the time (code: 110, length 3)
4. D occurs ⅛ of the time (code: 111, length 3)
The entropy of this source is ½(1) + ¼(2) + ⅛(3) + ⅛(3) = 1.75 bits. Because our codes match this average length of 1.75 bits per symbol, Shannon's theorem shows that, in the limit, no method can compress this source into fewer bits per symbol without information almost certainly being lost.
Fact-checked against Shannon's source coding theorem on Wikipedia
Part of the Mathematics syllabus: Computation, Information, and Strategy
See it on the timeline of Computation, Information, and Strategy