Quant Memo
Advanced

Mutual Information as a Dependence Measure

A way to measure how much knowing one variable tells you about another that, unlike correlation, catches any kind of dependence — curved, cyclical, or otherwise nonlinear — not just straight-line relationships.

Prerequisites: Entropy and Information, Correlation

You're screening candidate features for a signal and computing correlation with next-day return for each one. A feature has a correlation of 0.02 with the target — essentially useless by that measure — and you discard it. But suppose the true relationship is that the feature strongly predicts the magnitude of the next move (big feature value in either direction means a big move, in either direction) with no consistent sign — a U-shaped or symmetric nonlinear relationship. Correlation, which only measures straight-line co-movement, is blind to this entirely; it can report exactly zero for a feature that's actually a near-perfect predictor of volatility. You need a measure of dependence that doesn't assume the relationship is a straight line.

An analogy: guessing a friend's mood from the weather

Suppose you know almost nothing about how weather affects your friend's mood, and you want to measure how much knowing today's weather narrows down your guess about their mood. If weather and mood were completely unrelated, learning it's sunny wouldn't shift your guess about their mood at all — you'd still be spread across "happy," "grumpy," "tired" with the same uncertainty as before. But if sunny days reliably correlate with a happier mood and stormy days reliably correlate with either extreme (energized by a big project, or grumpy about the commute) — a relationship correlation would badly undersell because it's not a simple "up weather, up mood" line — mutual information still detects it, because it just asks: does knowing the weather shrink your uncertainty about mood at all, in any pattern, not specifically a linear one?

The measure, one symbol at a time

Recall entropy, H(Y)H(Y), measures how uncertain you are about a random variable YY before learning anything else — high entropy means YY could be almost anything with similar odds; low entropy means YY is fairly predictable already. Conditional entropy, H(YX)H(Y \mid X), measures how uncertain you remain about YY after learning XX. Mutual information is defined as the reduction in uncertainty:

I(X;Y)=H(Y)H(YX).I(X;Y) = H(Y) - H(Y \mid X) .

In plain English: mutual information is exactly how much learning XX shrinks your uncertainty about YY — if knowing XX tells you nothing new about YY, H(YX)=H(Y)H(Y\mid X) = H(Y) and I(X;Y)=0I(X;Y)=0; if knowing XX pins YY down completely, H(YX)=0H(Y\mid X)=0 and I(X;Y)=H(Y)I(X;Y)=H(Y), its maximum possible value. Unlike correlation, this definition never assumes the relationship between XX and YY has any particular shape — it works the same whether the dependence is linear, curved, cyclical, or a relationship in variance rather than level.

An equivalent, more computable form for discrete or binned variables:

I(X;Y)=x,yp(x,y)logp(x,y)p(x)p(y).I(X;Y) = \sum_{x,y} p(x,y) \log \frac{p(x,y)}{p(x)\,p(y)} .

In plain English: for every combination of XX-value and YY-value, compare how often that combination actually occurs, p(x,y)p(x,y), to how often it would occur if XX and YY were completely independent, p(x)p(y)p(x)p(y); if the actual joint frequency consistently differs from the independent prediction, I(X;Y)I(X;Y) is large — this is the same logic as a chi-squared independence test, but expressed in information units (bits, if using log2\log_2) rather than a test statistic.

Worked example 1: a U-shaped relationship correlation misses

Feature X{2,1,0,1,2}X \in \{-2, -1, 0, 1, 2\}, target Y=X2{4,1,0,1,4}Y = X^2 \in \{4, 1, 0, 1, 4\}, each value equally likely (p=0.2p=0.2). The sample correlation is exactly zero — XX has mean 0 and is symmetric, so positive and negative XX values contribute canceling terms to the covariance:

Cov(X,Y)=15i(xi0)(yiyˉ)=15[(2)(42)+(1)(12)+0+(1)(12)+(2)(42)]=15[4+1+01+4]=0.\text{Cov}(X,Y) = \frac{1}{5}\sum_i (x_i - 0)(y_i - \bar y) = \frac{1}{5}\big[(-2)(4-2) + (-1)(1-2) + 0 + (1)(1-2) + (2)(4-2)\big] = \frac{1}{5}[-4+1+0-1+4] = 0 .

Yet YY is a deterministic function of XX — knowing XX tells you YY exactly, with zero remaining uncertainty. Since H(YX)=0H(Y \mid X) = 0 (no uncertainty left once XX is known),

I(X;Y)=H(Y)0=H(Y).I(X;Y) = H(Y) - 0 = H(Y) .

With YY taking values {4,1,0,1,4}\{4,1,0,1,4\}, i.e., p(0)=0.2p(0)=0.2, p(1)=0.4p(1)=0.4, p(4)=0.4p(4)=0.4: H(Y)=0.2log20.20.4log20.40.4log20.40.464+0.529+0.529=1.522H(Y) = -0.2\log_2 0.2 - 0.4\log_2 0.4 - 0.4\log_2 0.4 \approx 0.464 + 0.529 + 0.529 = 1.522 bits. So I(X;Y)1.52I(X;Y) \approx 1.52 bits — a substantial, correctly detected dependence — while correlation reported exactly 0. This is precisely the U-shaped case a feature screen based on correlation alone would silently throw away.

Worked example 2: mutual information on a coarse feature screen

Bin a candidate feature into "low / medium / high" and next-day return into "down / flat / up," and tabulate observed frequencies from 900 days:

Return downReturn flatReturn upRow total
Feature low15050100300
Feature medium100100100300
Feature high5050200300

If feature and return were independent, each cell should be (row total × column total)/900; e.g., for "low, down": 300×300/900=100300 \times 300 / 900 = 100, versus the observed 150 — well above what independence predicts. Computing p(x,y)logp(x,y)p(x)p(y)p(x,y)\log\frac{p(x,y)}{p(x)p(y)} for every cell and summing (using p(low)=p(med)=p(high)=1/3p(\text{low})=p(\text{med})=p(\text{high})=1/3 and p(down)=300/900p(\text{down})=300/900, p(flat)=200/900p(\text{flat})=200/900, p(up)=400/900p(\text{up})=400/900) yields a positive I(X;Y)I(X;Y) of roughly 0.05–0.08 bits — small but clearly nonzero, correctly flagging that "high" feature values are associated with "up" days far more often than chance, a pattern that would also show up as nonzero correlation here, but mutual information reports it without ever assuming the relationship was linear in the first place, and generalizes immediately to features where it isn't.

X Y correlation ≈ 0, mutual information > 0
A perfect U-shaped relationship: correlation is exactly zero (positive and negative X cancel), but mutual information correctly reports strong dependence, since knowing X still tells you Y exactly.
H(X) H(Y) I(X;Y) shared uncertainty reduction
Mutual information is the overlap between two variables' entropy — the portion of uncertainty about Y that knowing X removes, regardless of what shape that dependence takes.

What this means in practice

Mutual information is a standard tool in feature screening pipelines precisely because correlation systematically misses non-monotonic relationships — volatility-predicting features, regime-dependent effects, and anything U-shaped or cyclical — that are common in market data. It's used alongside correlation, not as a replacement: correlation is cheap, interpretable, and tells you the sign of a linear relationship, which mutual information does not (it's always non-negative and tells you only how much dependence exists, not its direction or shape). In practice it requires binning or density estimation for continuous variables, which introduces its own choices (bin width interacts with the same bias-variance trade-off as kernel density estimation), and it needs meaningfully more data than correlation to estimate reliably, especially with many bins.

Mutual information measures how much knowing one variable reduces your uncertainty about another, and unlike correlation it detects any form of statistical dependence — not just linear — because it's built from entropy, not from covariance. A feature can have zero correlation with a target and still carry substantial mutual information, as in a purely nonlinear or U-shaped relationship.

The classic mistake is treating mutual information as a drop-in numerical replacement for correlation and comparing raw values across feature pairs computed with different binning schemes or sample sizes — mutual information estimates are sensitive to bin count and are systematically biased upward with fewer bins and less data (more bins can spuriously "explain" the training sample). Always compare mutual information estimates computed with the same binning and sample size, and validate any high-MI, low-correlation feature out-of-sample before trusting it — a nonlinear pattern found by mutual information in a small sample is exactly the kind of thing that's prone to overfitting the binning choice.

Related concepts

Practice in interviews

Further reading

  • Cover & Thomas, Elements of Information Theory, ch. 2 & 8
  • López de Prado, Advances in Financial Machine Learning, ch. 3
ShareTwitterLinkedIn