Mutual Information

How much knowing one thing tells you about another, even when the link is not a straight line.

🔴 advanced5 min readinformation-theory
Mutual information measures how much knowing one thing reduces your uncertainty about another. If knowing someone's postcode tells you a lot about their income, the two share a lot of mutual information. Unlike correlation, which only catches straight-line relationships, it catches any kind of dependence, including curved or patchy ones, and it is zero only when the two are truly unrelated. It is used to pick useful features, and it is the idea behind contrastive learning, which trains models by matching related pairs.

What is Mutual Information?

Mutual Information I(X;Y)I(X; Y) measures how much knowing variable YY reduces uncertainty about variable XX.

                       INFORMATION THEORY VENN DIAGRAM
                     ┌───────────────────┬───────────────────┐
                     │   Entropy H(X)    │   Entropy H(Y)    │
                     │                   │                   │
                     │         ┌─────────┴─────────┐         │
                     │         │ MUTUAL INFO I(X;Y)│         │
                     │ H(X|Y)  │  Joint overlap    │ H(Y|X)  │
                     │         │                   │         │
                     └─────────┴───────────────────┴─────────┘

Three Equivalent Formulations

  1. Entropy Reduction:
I(X;Y)=H(X)−H(X∣Y)=H(Y)−H(Y∣X)I(X; Y) = H(X) - H(X \mid Y) = H(Y) - H(Y \mid X)
  1. Symmetric Joint Overlap:
I(X;Y)=H(X)+H(Y)−H(X,Y)I(X; Y) = H(X) + H(Y) - H(X, Y)
  1. KL Divergence from Independence:
I(X;Y)=DKL(P(X,Y)∥P(X)P(Y))=∑x∈X∑y∈YP(x,y)log⁡P(x,y)P(x)P(y)I(X; Y) = D_{KL}\left( P(X, Y) \parallel P(X) P(Y) \right) = \sum_{x \in X} \sum_{y \in Y} P(x, y) \log \frac{P(x, y)}{P(x) P(y)}

Pearson Correlation vs Mutual Information

Consider data generated by y=x2y = x^2 for x∼Uniform(−1,1)x \sim \text{Uniform}(-1, 1):

  y = x^2 (Parabola)
  y
  1 ┤  *       *
    │   *     *
  0 ┴────*──*──*────► x
       -1   0  1

Applications in Machine Learning

  1. Non-Linear Feature Selection: Rank features XiX_i by I(Xi;Y)I(X_i; Y) with target variable YY, filtering out irrelevant features regardless of model architecture.
  2. Contrastive Representation Learning (InfoNCE): Self-supervised models (SimCLR, CLIP) maximize InfoNCE loss:
LInfoNCE=−E[log⁡exp⁡(sim(zi,zj)/τ)∑kexp⁡(sim(zi,zk)/τ)]\mathcal{L}_{\text{InfoNCE}} = -\mathbb{E} \left[ \log \frac{\exp(\text{sim}(z_i, z_j) / \tau)}{\sum_k \exp(\text{sim}(z_i, z_k) / \tau)} \right]

InfoNCE maximizes a lower bound on Mutual Information I(zi;zj)I(z_i; z_j) between augmented views of the same image!

Say this out loud

Mutual Information I(X;Y) measures how much knowing Y reduces uncertainty about X, calculated as H(X) - H(X|Y) or KL divergence between joint P(X,Y) and independent product P(X)P(Y). Unlike Pearson correlation which finds only linear patterns, Mutual Information detects arbitrary non-linear dependencies, underpinning non-linear feature selection and contrastive InfoNCE representation learning.

Follow-ups to expect

Check yourself

Question 1 of 3

What is the relationship between Mutual Information I(X; Y) and Marginal Entropy H(X), Conditional Entropy H(X|Y), and KL Divergence?

More in Math & Statistics

See all →
Bayes’ Theorem4 minCentral Limit Theorem4 minLaw of Large Numbers4 min