The Data-Processing Inequality
No amount of clever processing can create information about the source that was not in the data. If you compress, filter, quantize or feed data through a neural network, the result can tell you at most as much about the original signal as the data did. This is the data-processing inequality.
Markov chains
Three random variables form a Markov chain if depends on only through :
Typical example: is a message, the noisy signal received, the output of any decoder applied to . Equivalently, and are conditionally independent given (Markov Chains).
The inequality
If , then
Proof. Expand with the chain rule for mutual information in two ways:
The Markov property gives , and , so .
import numpy as np
def mi(P):
Q = np.outer(P.sum(axis=1), P.sum(axis=0)); nz = P > 0
return float(np.sum(P[nz] * np.log2(P[nz] / Q[nz])))
rng = np.random.default_rng(0)
worst = -np.inf
for _ in range(3000):
px = rng.dirichlet(np.ones(4))
A = rng.dirichlet(np.ones(5), size=4) # P(y | x), rows sum to 1
B = rng.dirichlet(np.ones(3), size=5) # P(z | y)
Pxy = px[:, None] * A
Pxz = Pxy @ B
worst = max(worst, mi(Pxz) - mi(Pxy))
print("largest I(X;Z) - I(X;Y) over 3000 random chains:", round(worst, 4), "(never positive)")largest I(X;Z) - I(X;Y) over 3000 random chains: -0.0155 (never positive)
Two channels in a row
Sending a bit through two binary symmetric channels with flip probability 0.1 each is like one channel with flip probability . The information about drops at each stage:
import numpy as np
def mi(P):
Q = np.outer(P.sum(axis=1), P.sum(axis=0)); nz = P > 0
return float(np.sum(P[nz] * np.log2(P[nz] / Q[nz])))
bsc = lambda f: np.array([[1 - f, f], [f, 1 - f]])
px = np.array([0.5, 0.5])
P = np.diag(px) # joint of X with itself
for stage in range(4):
print(f"after {stage} channels: I(X; output) = {mi(P):.4f} bits")
P = P @ bsc(0.1)after 0 channels: I(X; output) = 1.0000 bits
after 1 channels: I(X; output) = 0.5310 bits
after 2 channels: I(X; output) = 0.3199 bits
after 3 channels: I(X; output) = 0.1984 bits
Sufficient statistics
Equality holds when keeps everything in that is relevant to ; such a is a sufficient statistic. For coin flips with unknown bias , the number of heads is sufficient: the order of the flips carries no further information about .
import numpy as np
from itertools import product
thetas = np.array([0.2, 0.5, 0.8]); prior = np.ones(3) / 3
n = 4
seqs = list(product([0, 1], repeat=n))
P_seq = np.array([[t**sum(s) * (1 - t)**(n - sum(s)) for s in seqs] for t in thetas]) * prior[:, None]
P_count = np.zeros((3, n + 1))
for j, s in enumerate(seqs):
P_count[:, sum(s)] += P_seq[:, j]
def mi(P):
Q = np.outer(P.sum(axis=1), P.sum(axis=0)); nz = P > 0
return float(np.sum(P[nz] * np.log2(P[nz] / Q[nz])))
print("I(theta; full sequence) =", round(mi(P_seq), 6))
print("I(theta; head count) =", round(mi(P_count), 6))
print("I(theta; first flip) =", round(mi(np.array([P_seq[:, [j for j, s in enumerate(seqs) if s[0] == b]].sum(axis=1) for b in (0, 1)]).T), 6))I(theta; full sequence) = 0.54293
I(theta; head count) = 0.54293
I(theta; first flip) = 0.185381
What it means in practice
- Feature engineering cannot add information about the label; it can only make the existing information easier for a model to use.
- In a deep network, each layer is a function of the previous one, so can only decrease with depth. The information bottleneck view of learning builds on this (The Information Bottleneck).
- A decoder can never recover more information than the channel let through, which is the starting point of the converse of the coding theorem (Why You Cannot Beat Capacity).
In software
- When building a pipeline (sensor, compression, feature extraction, model), measure mutual information or accuracy after each stage: the numbers can only go down, and a stage with a big drop is where information is lost.
Exercises
Exercise 1: Deterministic processing
If for a function , is a Markov chain?
Answer
Yes, for every .
Solution
Given , is fixed, so it is conditionally independent of . Hence .
Exercise 2: One-to-one processing
If is one-to-one, compare and .
Answer
They are equal.
Solution
Apply the inequality to and to (since ).
Exercise 3: Quantization loses information (code)
is uniform on and where is uniform on . Compute and .
Answer
About 2.125 bits and 1.703 bits.
Solution
import numpy as np
def mi(P):
Q = np.outer(P.sum(axis=1), P.sum(axis=0)); nz = P > 0
return float(np.sum(P[nz] * np.log2(P[nz] / Q[nz])))
Pxy = np.zeros((8, 9))
for x in range(8):
for n in (0, 1):
Pxy[x, x + n] += 1 / 16
Pxz = np.zeros((8, 5))
for y in range(9):
Pxz[:, y // 2] += Pxy[:, y]
print(round(mi(Pxy), 4), round(mi(Pxz), 4))2.125 1.7028
Test yourself
If is a Markov chain, then…
A statistic T(Y) is sufficient for X when…
- T is linear
Two BSCs with flip probability 0.1 in a row act like one BSC with flip probability…
- 0.18
- 0.2
- 0.1
- 0.01