Mutual Information

Mutual information measures how much knowing one variable reduces uncertainty about another. It is zero exactly when the variables are independent, and positive when their joint distribution carries structure beyond separate marginals in the sense of conditional probability.

Defining math

For discrete variables,

Here is the joint probability of a pair of outcomes, while and are the marginal probabilities each variable would have on its own. The ratio compares the observed joint probability with what independence would predict; the log term is zero when the two match and nonzero when knowing one variable changes expectations about the other.

Equivalently, using entropy,

This form says mutual information is uncertainty removed: is the uncertainty in before seeing , and is the remaining uncertainty after is known.

The first formula shows mutual information as a KL divergence:

That connection ties MI to information theory, feature selection, representation learning, and diagnostics for dependence beyond linear correlation. It is related to cross-entropy through the same expected-log-probability algebra, but it compares dependence rather than predictive code length.

Worked example

Consider two binary variables whose joint table puts probability on matching outcomes and , and probability on mismatches and . Each marginal is still balanced at , so independence would assign to every cell. The matching cells are therefore more likely than independence predicts, and the mismatch cells are less likely.

Plugging those four cells into gives about bits of shared information. If the joint table were exactly the product of its marginals, every ratio inside the log would be , every log term would be , and the mutual information would be because knowing would not change the probabilities for .

Caveats

Mutual information is hard to estimate from finite continuous data without modeling or binning choices. It detects dependence but not direction or causality, and high-cardinality variables can produce biased empirical estimates.

References