TExcelTAD
Home › Information Theory › The Data-Processing Inequality

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 X→Y→ZX \to Y \to Z if ZZ depends on XX only through YY:

P(x,y,z)=P(x) P(y∣x) P(z∣y)P(x, y, z) = P(x)\,P(y \mid x)\,P(z \mid y)

Typical example: XX is a message, YY the noisy signal received, ZZ the output of any decoder applied to YY. Equivalently, XX and ZZ are conditionally independent given YY (Markov Chains).

The inequality

If X→Y→ZX \to Y \to Z, then

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

Proof. Expand I(X;Y,Z)I(X; Y, Z) with the chain rule for mutual information in two ways:

I(X;Y,Z)=I(X;Z)+I(X;Y∣Z)=I(X;Y)+I(X;Z∣Y)I(X; Y, Z) = I(X; Z) + I(X; Y \mid Z) = I(X; Y) + I(X; Z \mid Y)

The Markov property gives I(X;Z∣Y)=0I(X; Z \mid Y) = 0, and I(X;Y∣Z)≥0I(X; Y \mid Z) \ge 0, so I(X;Z)≤I(X;Y)I(X; Z) \le I(X; Y).

python · try it yourself
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 0.1⋅0.9+0.9⋅0.1=0.180.1 \cdot 0.9 + 0.9 \cdot 0.1 = 0.18. The information about XX drops at each stage:

python · try it yourself
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 I(X;Z)=I(X;Y)I(X; Z) = I(X; Y) holds when ZZ keeps everything in YY that is relevant to XX; such a ZZ is a sufficient statistic. For nn coin flips with unknown bias θ\theta, the number of heads is sufficient: the order of the flips carries no further information about θ\theta.

python · try it yourself
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 I(label;layerk)I(\text{label}; \text{layer}_k) 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 Z=g(Y)Z = g(Y) for a function gg, is X→Y→ZX \to Y \to Z a Markov chain?

Answer

Yes, for every XX.

Solution

Given YY, ZZ is fixed, so it is conditionally independent of XX. Hence I(X;g(Y))≤I(X;Y)I(X; g(Y)) \le I(X; Y).

Exercise 2: One-to-one processing

If gg is one-to-one, compare I(X;g(Y))I(X; g(Y)) and I(X;Y)I(X; Y).

Answer

They are equal.

Solution

Apply the inequality to X→Y→g(Y)X \to Y \to g(Y) and to X→g(Y)→YX \to g(Y) \to Y (since Y=g−1(g(Y))Y = g^{-1}(g(Y))).

Exercise 3: Quantization loses information (code)

XX is uniform on {0,1,…,7}\{0, 1, \dots, 7\} and Y=X+NY = X + N where NN is uniform on {0,1}\{0, 1\}. Compute I(X;Y)I(X; Y) and I(X;⌊Y/2⌋)I(X; \lfloor Y/2 \rfloor).

Answer

About 2.125 bits and 1.703 bits.

Solution
python · try it yourself
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 X→Y→ZX \to Y \to Z is a Markov chain, then…

  1. I(X;Z)≤I(X;Y)I(X; Z) \le I(X; Y)
  2. I(X;Z)≥I(X;Y)I(X; Z) \ge I(X; Y)
  3. I(X;Z)=0I(X; Z) = 0
  4. H(Z)≥H(Y)H(Z) \ge H(Y)

A statistic T(Y) is sufficient for X when…

  1. I(X;T(Y))=I(X;Y)I(X; T(Y)) = I(X; Y)
  2. H(T(Y))=0H(T(Y)) = 0
  3. T is linear
  4. I(X;T(Y))=0I(X; T(Y)) = 0

Two BSCs with flip probability 0.1 in a row act like one BSC with flip probability…

  1. 0.18
  2. 0.2
  3. 0.1
  4. 0.01