Skip to content
Kudos AI
Lire en français
Information Theory

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.

7 min readKudos AI

Prerequisites: Probability and Statistical Foundations

Four probabilities collapsing into a binary tree whose average length lands exactly on the entropy, a code book built for the wrong distribution charging a visible surcharge, and two inputs that say nothing separately determining a target together.

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 12\tfrac12, 14\tfrac14, 18\tfrac18, 18\tfrac18. The entropy is

H=∑xp(x)log⁡21p(x)=1.75 bitsH = \sum_x p(x)\log_2\frac{1}{p(x)} = 1.75 \text{ bits}

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 log⁡2(1/p)\log_2(1/p) happens to be a whole number here. Change the source to (0.6, 0.25, 0.1, 0.05)(0.6,\ 0.25,\ 0.1,\ 0.05) 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

A0.50001 vs 1.00B0.250102 vs 2.00C0.1251103 vs 3.00D0.1251113 vs 3.00
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 sizebits per symbol
11.5500
21.5275
31.5026
41.4983
the bound1.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 pp. So code that same source with the optimal code for a different distribution qq - say the uniform one - and measure the bill:

2.0000⏟H(p,q)=1.4905⏟H(p)+0.5095⏟KL(p∥q)\underbrace{2.0000}_{H(p,q)} = \underbrace{1.4905}_{H(p)} + \underbrace{0.5095}_{\mathrm{KL}(p\|q)}

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. H(p)H(p) 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. KL(p∥q)\mathrm{KL}(p\|q) 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.

0.000.300.60ABCD
source pmodel q

Where the bits go: p(x) log2(1/q(x))

0.000.601.20ABCD
unavoidablewasted
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.

directionbits
KL(source || uniform)1.4235
KL(uniform || source)2.8540

The same two distributions, and one direction costs just over twice the other.

KL(p∥q)\mathrm{KL}(p\|q) is dominated by outcomes that pp produces and qq calls unlikely, so minimising it spreads the model out to cover what happens. KL(q∥p)\mathrm{KL}(q\|p) 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 log⁡2(1/q(truth))\log_2(1/q(\text{truth})):

probability the model gave the truthloss
0.51.00 bits
0.13.32 bits
0.016.64 bits
0.0019.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 ff, the capacity is 1−H(f)1 - H(f):

flip probabilitybits carried per use
0.001.0000
0.100.5310
0.250.1887
0.500.0000

At f=0.1f = 0.1 the channel is right nine times out of ten and carries barely half a bit: accuracy and information are not the same currency. At f=0.5f = 0.5 it carries nothing at all, because the output distribution is then identical whatever was sent. At f=0.9f = 0.9 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:

measurementvalue
correlation of one input with the target+0.0016
mutual information of one input with the target0.0000 bits
mutual information of the pair with the target1.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 X→Y→ZX \to Y \to Z,

I(X;Z)≤I(X;Y)I(X;Z) \le I(X;Y)

because ZZ is computed from YY and sees nothing of XX except what YY 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.

1 bit0.5
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.

Related reading

4 min readProbability Foundations

Which Wrong Distribution Do You Want?

One bimodal target, one Gaussian, and two directions of the same divergence. Minimising KL(P||Q) puts the Gaussian across both modes with almost no mass where the target actually lives; minimising KL(Q||P) puts it on one mode at a value of 0.6931 nats, which is ln 2 to four decimals and not a coincidence. Each fit is judged catastrophic by the other objective, 2.0976 against 15.2799.

Machine LearningMathematics
3 min readProbability Foundations

The Two Features That Look Like Noise

A variable that determines another with a correlation of exactly 0.0000000000, and a pair of features whose every pairwise mutual information with the target is exactly zero while the two together determine it completely. Univariate screening discards both, and the second case is the one that matters: the features it removes are removed because they matter.

Machine LearningMathematics
10 min readProbability Foundations

Entropy and Information

Measuring uncertainty in bits: Shannon entropy and why the logarithm is base 2, information gain worked on a split, and how cross-entropy and KL divergence relate to entropy and to the loss functions used to train classifiers.

Information TheoryProbabilityMathematics
← Back to all articles