TExcelTAD
Home › Information Theory › Fano's Inequality

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 XX is still very uncertain after observing YY, then every way of guessing XX from YY must make many mistakes. It is the key tool in proving that rates above capacity are impossible.

Statement

Let X^\hat X be any estimate of XX computed from YY, with error probability Pe=P(X^≠X)P_e = P(\hat X \ne X), and let XX take NN values. Then

H(X∣Y)≤H2(Pe)+Pelog⁡2(N−1)H(X \mid Y) \le H_2(P_e) + P_e\log_2(N - 1)

A weaker but simpler form, using H2(Pe)≤1H_2(P_e) \le 1:

Pe≥H(X∣Y)−1log⁡2NP_e \ge \frac{H(X \mid Y) - 1}{\log_2 N}

Why it holds

Let EE be the indicator of an error. Knowing XX and X^\hat X determines EE, so by the chain rule H(X∣X^)≤H(E)+H(X∣E,X^)H(X \mid \hat X) \le H(E) + H(X \mid E, \hat X). Without an error, X=X^X = \hat X and there is nothing left to learn; with an error (probability PeP_e), XX is one of the other N−1N - 1 values, at most log⁡2(N−1)\log_2(N - 1) bits. Finally H(X∣Y)≤H(X∣X^)H(X \mid Y) \le H(X \mid \hat X) by the data-processing inequality (The Data-Processing Inequality).

Checking it numerically

For random joint distributions, the best possible guess is the MAP rule x^(y)=arg⁡max⁡xP(x∣y)\hat x(y) = \arg\max_x P(x \mid y). Its error probability always satisfies Fano's bound:

python · try it yourself
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 PeP_e gives the smallest error probability compatible with a given H(X∣Y)H(X \mid Y). Here is that bound as a function of the remaining uncertainty, for N=16N = 16:

python · try it yourself
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 M=2nRM = 2^{nR} messages is used nn times over a channel of capacity CC. The output carries at most nCnC bits about the message, so H(W∣Yn)≥nR−nCH(W \mid Y^n) \ge nR - nC. If R>CR > C, Fano's inequality forces PeP_e 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 H(Y∣X)H(Y \mid X) for labels YY and features XX, 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 Pe=0P_e = 0, what does Fano's inequality say about H(X∣Y)H(X \mid Y)?

Answer

H(X∣Y)=0H(X \mid Y) = 0.

Solution

The right side is H2(0)+0=0H_2(0) + 0 = 0, and conditional entropy is non-negative. Error-free decoding means YY determines XX.

Exercise 2: Simple bound

XX is one of 1024 messages and H(X∣Y)=6H(X \mid Y) = 6 bits. What does the simple form give for PeP_e?

Answer

Pe≥0.5P_e \ge 0.5.

Solution

6−1log⁡21024=510=0.5\frac{6 - 1}{\log_2 1024} = \frac{5}{10} = 0.5.

Exercise 3: Binary case (code)

For N=2N = 2, Fano reads H(X∣Y)≤H2(Pe)H(X \mid Y) \le H_2(P_e). If H(X∣Y)=0.5H(X \mid Y) = 0.5 bits, find the smallest possible PeP_e numerically.

Answer

About 0.110.

Solution
python · try it yourself
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…

  1. the error probability of any estimator from below, given H(X∣Y)H(X \mid Y)
  2. the entropy from below
  3. the capacity from above
  4. the code length of Huffman codes

Fano's inequality is the key step in proving…

  1. the converse of the channel coding theorem
  2. Kraft's inequality
  3. the optimality of Huffman codes
  4. the chain rule

Which estimator gives the smallest error probability?

  1. the MAP rule arg⁡max⁡xP(x∣y)\arg\max_x P(x \mid y)
  2. always guessing the first value
  3. a random guess
  4. the maximum-entropy guess