Fano's Inequality
Entropy tells us how uncertain we are; error probability tells us how often a guess is wrong. Fano's inequality links the two: if is still very uncertain after observing , then every way of guessing from must make many mistakes. It is the key tool in proving that rates above capacity are impossible.
Statement
Let be any estimate of computed from , with error probability , and let take values. Then
A weaker but simpler form, using :
Why it holds
Let be the indicator of an error. Knowing and determines , so by the chain rule . Without an error, and there is nothing left to learn; with an error (probability ), is one of the other values, at most bits. Finally by the data-processing inequality (The Data-Processing Inequality).
Checking it numerically
For random joint distributions, the best possible guess is the MAP rule . Its error probability always satisfies Fano's bound:
import numpy as np
def H(p):
p = np.asarray(p, float).ravel(); p = p[p > 0]
return float(-np.sum(p * np.log2(p))) + 0.0
H2 = lambda e: H([e, 1 - e])
rng = np.random.default_rng(0)
N = 5
for trial in range(5):
P = rng.dirichlet(np.ones(N * 4) * 0.5).reshape(N, 4) # joint of X (rows) and Y (columns)
H_X_given_Y = H(P) - H(P.sum(axis=0))
Pe = 1 - P.max(axis=0).sum() # MAP decoder errors
bound = H2(Pe) + Pe * np.log2(N - 1)
print(f"H(X|Y) = {H_X_given_Y:.3f} <= H2(Pe) + Pe log2(N-1) = {bound:.3f} (Pe = {Pe:.3f})")H(X|Y) = 1.879 <= H2(Pe) + Pe log2(N-1) = 2.110 (Pe = 0.560)
H(X|Y) = 1.847 <= H2(Pe) + Pe log2(N-1) = 2.088 (Pe = 0.547)
H(X|Y) = 1.305 <= H2(Pe) + Pe log2(N-1) = 1.651 (Pe = 0.356)
H(X|Y) = 1.537 <= H2(Pe) + Pe log2(N-1) = 2.044 (Pe = 0.523)
H(X|Y) = 1.358 <= H2(Pe) + Pe log2(N-1) = 1.779 (Pe = 0.403)
The lower bound on the error
Solving Fano's inequality for gives the smallest error probability compatible with a given . Here is that bound as a function of the remaining uncertainty, for :
import numpy as np
def fano_rhs(pe, N):
h = 0.0 if pe in (0, 1) else -pe * np.log2(pe) - (1 - pe) * np.log2(1 - pe)
return h + pe * np.log2(N - 1)
N = 16
pes = np.linspace(0, 1 - 1 / N, 100_001)
rhs = np.array([fano_rhs(p, N) for p in pes])
for h in [0.5, 1.0, 2.0, 3.0, 3.9]:
print(f"H(X|Y) = {h:3.1f} bits -> Pe >= {pes[np.argmax(rhs >= h)]:.4f}")H(X|Y) = 0.5 bits -> Pe >= 0.0523
H(X|Y) = 1.0 bits -> Pe >= 0.1203
H(X|Y) = 2.0 bits -> Pe >= 0.2897
H(X|Y) = 3.0 bits -> Pe >= 0.5120
H(X|Y) = 3.9 bits -> Pe >= 0.8297
With 16 messages, if 2 bits of uncertainty remain after decoding, at least about 29% of decisions must be wrong.
Why it matters
In the converse of the channel coding theorem, a code with messages is used times over a channel of capacity . The output carries at most bits about the message, so . If , Fano's inequality forces to stay bounded away from zero (Why You Cannot Beat Capacity).
In software
- Fano's bound gives a quick sanity check for classifiers: from an estimate of for labels and features , no classifier can have error below the Fano bound. If yours does, the estimate is wrong or the test set leaked.
Exercises
Exercise 1: Zero error
If , what does Fano's inequality say about ?
Answer
.
Solution
The right side is , and conditional entropy is non-negative. Error-free decoding means determines .
Exercise 2: Simple bound
is one of 1024 messages and bits. What does the simple form give for ?
Answer
.
Solution
.
Exercise 3: Binary case (code)
For , Fano reads . If bits, find the smallest possible numerically.
Answer
About 0.110.
Solution
import numpy as np
from scipy.optimize import brentq
H2 = lambda p: -p * np.log2(p) - (1 - p) * np.log2(1 - p)
print(round(brentq(lambda p: H2(p) - 0.5, 1e-9, 0.5), 4))0.11
Test yourself
Fano's inequality bounds…
- the error probability of any estimator from below, given
- the entropy from below
- the capacity from above
- the code length of Huffman codes
Fano's inequality is the key step in proving…
- the converse of the channel coding theorem
- Kraft's inequality
- the optimality of Huffman codes
- the chain rule
Which estimator gives the smallest error probability?
- the MAP rule
- always guessing the first value
- a random guess
- the maximum-entropy guess