The Bound That Is Actually Reached
Entropy is not a summary of a distribution but a floor that the best code meets to the last decimal, the surcharge for using the wrong distribution is exactly the loss every classifier already minimises, and mutual information puts a hard ceiling on everything downstream of a sensor. Three results, each unusually sharp.
Prerequisites: Probability and Statistical Foundations
Most bounds in machine learning are loose. You prove that some error is at most something, the something is enormous, and the value of the result is its shape rather than its number.
Information theory is the exception, and that is what makes it worth a few hours. Three of its central quantities are bounds that are attained, and each one turns out to be something you already use without calling it by that name.
One: the shortest a code can be
Take four symbols with probabilities , , , . The entropy is
Now build the best prefix code by repeatedly merging the two least likely symbols. The lengths come out as 1, 2, 3 and 3 bits, which average to 1.7500 bits - the entropy, to every decimal place. A fixed-length code would need 2 bits, so the saving is 12.5%.
The match is exact because each ideal length happens to be a whole number here. Change the source to and it stops being exact: entropy 1.4905, best code 1.5500. The ideal length for a symbol of probability 0.6 is 0.737 bits, and no code word is 0.737 bits long.
Interactive: build the code, then try to beat the bound
The code is constructed for whatever you set, not looked up.
The code words, and the length each symbol deserved
- Entropy
- 1.7500
- Code average
- 1.7500
- Gap
- 0.0000
- Bits per symbol
- 1.7500
The code averages exactly the entropy, with nothing left over. That happens when every probability is a power of two: the ideal length log2(1/p) is then a whole number, and the code can afford to give each symbol precisely the length it deserved. Move any slider off a power of two and a gap appears immediately.
The fix is to code several symbols at once, so the rounding error is shared:
| block size | bits per symbol |
|---|---|
| 1 | 1.5500 |
| 2 | 1.5275 |
| 3 | 1.5026 |
| 4 | 1.4983 |
| the bound | 1.4905 |
Approaching from above, never crossing. Note what is not happening: the symbols are independent, so there is no redundancy between them to exploit and the entropy per symbol never changes. Only the granularity improves.
The practical reading is the one worth keeping. If a compressor beats the entropy you computed, the theorem is not in trouble - your distribution was wrong. Entropy is a statement about a model, which makes it a modelling tool rather than a property of a file.
Two: what the wrong distribution costs
You never know . So code that same source with the optimal code for a different distribution - say the uniform one - and measure the bill:
Exactly two bits per symbol, splitting exactly into the entropy of the source plus a surcharge. That surcharge is the Kullback-Leibler divergence.
Look at what each term depends on. is a property of the world: no model changes it, and it is the information-theoretic twin of the irreducible error in the bias-variance decomposition. is entirely your model.
So minimising cross-entropy over models is minimising divergence from the truth, exactly. Two things follow immediately: the loss can never reach zero on a noisy source, so a training loss approaching zero means memorisation rather than learning; and minimising cross-entropy is maximum likelihood in different units.
Interactive: the bits a wrong model costs
The source is fixed. Move the model and watch the floor stay put.
Where the bits go: p(x) log2(1/q(x))
- H(p)
- 1.4905 bits
- H(p, q)
- 2.0000 bits
- KL(p || q)
- 0.5095 bits
- KL(q || p)
- 0.5952 bits
You are paying 0.5095 bits per symbol more than the source requires - 6.4% of a byte thrown away on every symbol, forever. Most of it comes from A: the model gives it a 2.00-bit code word and the source keeps producing it, which wastes 0.758 bits of the average on that symbol alone. Note that this is not the symbol the model gets most wrong - it is the one that is wrong and common.
It is not a distance
Take a source that emits one symbol 98% of the time.
| direction | bits |
|---|---|
| KL(source || uniform) | 1.4235 |
| KL(uniform || source) | 2.8540 |
The same two distributions, and one direction costs just over twice the other.
is dominated by outcomes that produces and calls unlikely, so minimising it spreads the model out to cover what happens. punishes the reverse, so minimising it makes the model commit to one region. Which one a method minimises is a modelling decision, and it is why variational approaches that take the second direction are mode-seeking.
And it is unbounded
The loss on one example is :
| probability the model gave the truth | loss |
|---|---|
| 0.5 | 1.00 bits |
| 0.1 | 3.32 bits |
| 0.01 | 6.64 bits |
| 0.001 | 9.97 bits |
A model that is right 95% of the time while being certain on the 5% it gets wrong scores far worse than one that is right as often and hedges. Accuracy cannot see that difference; cross-entropy is built from it. It also explains a loss curve that spikes while accuracy does not move - a few confidently wrong examples dominating the gradient.
Three: what one variable says about another
The same machinery, applied to a pair, answers an engineering question and a modelling question with one number.
For a channel that flips each bit with probability , the capacity is :
| flip probability | bits carried per use |
|---|---|
| 0.00 | 1.0000 |
| 0.10 | 0.5310 |
| 0.25 | 0.1887 |
| 0.50 | 0.0000 |
At the channel is right nine times out of ten and carries barely half a bit: accuracy and information are not the same currency. At it carries nothing at all, because the output distribution is then identical whatever was sent. At it is back to 0.5310 - a consistent liar is as useful as a consistent truth-teller.
The dependence correlation reports as zero
Generate two independent bits and let the target be their XOR. Over 200,000 draws:
| measurement | value |
|---|---|
| correlation of one input with the target | +0.0016 |
| mutual information of one input with the target | 0.0000 bits |
| mutual information of the pair with the target | 1.0000 bit |
Every reading is correct. Neither input alone says anything - and mutual information, which would catch a dependence of any shape rather than a linear one only, agrees. The pair determines the target exactly.
So any feature screening that ranks variables one at a time discards both of them, with a perfectly clean report. This is not exotic: a drug that works only in the presence of a gene, a fault that occurs only when two settings disagree. The fix is to score subsets, or to let a model that represents interactions see them together.
One caution: mutual information is harder to estimate than a correlation. On continuous variables it depends on binning, and it is biased upward on small samples, so a high value on few points can be the estimator talking.
The ceiling nothing raises
Measure the 10% channel and you get 0.5329 bits about what was sent, matching the theoretical 0.5310. Erase three received bits in ten to 0 and measure again: 0.2763 bits.
It went down, and no processing can ever push it back up. For any chain ,
because is computed from and sees nothing of except what passed on. The consequences are blunt:
- codes work by adding redundancy before transmission; no decoder recovers what the channel destroyed
- no model, however deep, extracts more about the label than its features carry - layers are functions of layers, and the ceiling is set at the input
- every preprocessing step, from quantising to dropping a column, can only lose information, which may be the right trade but should be a decision rather than housekeeping
The text above erases bits; the figure instead uses a second 10% channel in series. With both flip probabilities at 0.10 its After processing reads 0.3199 bits rather than the 0.2763 above, and both sit below what the channel carried. The inequality holds for every choice; the number depends on which one you make.
Interactive: what a channel carries, and what it never gets back
Exact, from the joint distribution. No sampling anywhere.
- Bits per use
- 0.5310
- After processing
- 0.3199
- Lost to processing
- 0.2111
- Composite flip
- 0.1800
A channel that flips with probability 0.10 is right 90% of the time and still carries only 0.5310 bits per use. Accuracy and information are not the same currency. Now send the output through a second channel at 0.10: the composite flip probability is 0.1800 and what survives is 0.3199 bits. It fell, and it always will. That is the data processing inequality, shown here with a cascade because the arithmetic is checkable, but it holds for any function of the received signal whatever.
Why this keeps reappearing
Compression, communication and the loss functions of machine learning are the same three quantities wearing different clothes. Entropy is the floor. Cross entropy is what you pay when your distribution is wrong, and its excess over the floor is what your optimiser has been reducing all along. Mutual information is what one variable says about another, and it bounds everything downstream.
None of them is a heuristic, which is rare enough in this field to be worth the afternoon it takes to learn them properly.
References & further reading
- David J. C. MacKay, Information Theory, Inference, and Learning Algorithms, Cambridge University Press, 2003source ↗
- Thomas M. Cover, Joy A. Thomas, Elements of Information Theory, Wiley (2nd edition), 2006· Kudos AI reference library
Copyrighted works are cited for reference only and are not hosted here; please consult the publisher for access.