Joint and Conditional Entropy
Pairs carry joint surprise; knowing one variable discounts the other. The chain rule splits the pair into staged, additive predictions.
Why Does This Exist?
Features arrive in bundles: pixels, tokens, sensor channels. Pricing the bundle by adding up single-variable surprises overcounts whenever variables share information, and it never undercounts. A compressor that budgets 1 bit per fair coin needs 2 bits for two independent coins but only 1.722 bits for the correlated pair below. Feature selection, sequential prediction, and compression all need two numbers: the price of the pair and the discount for knowing one side.
This page defines both numbers and the rule that links them. It extends entropy from one variable to two and sets up mutual information as the overlap they share.
The one idea you need first
Entropy averages . A fair coin gives bit. Joint entropy runs the same average over pairs. Conditional entropy subtracts what already told you about .
Think of It Like This
Two weather reporters
Two reporters cover neighboring towns. Reading both reports fresh takes two minutes. Reading the second after the first takes less, because shared weather is old news.
Independent towns give no discount. Identical towns make the second report free. The mapping is exact: the pair is the joint, the leftover read is the conditional, and the saved time is the overlap.
Where it stops: reporters editorialize and add noise. Conditional entropy assumes the true joint distribution, not two biased retellings.
How It Actually Works
For discrete and with joint chances , define the pair price:
In plain words: average the surprise over pairs instead of singles. Define the remainder after knowing :
In plain words: start from the pair price and subtract what alone already cost. Averaging over gives the same number. The chain rule links them:
In plain words: predict first, then predict with known. The total never depends on order, so . For variables the chain telescopes to .
Two facts organize practice. Conditioning never increases entropy, so with equality exactly for independence. The discount has a name: . Estimation from counts needs smoothing, because plug-in estimates miss unseen pairs and run low.
Worked example
Two independent fair coins give four pairs at each:
Here and , so the chain reads .
Now correlate them: , , , . Margins stay fair at 1 bit each. With and :
Then bits and bits. Correlation donated 0.278 bits of discount, which is exactly the overlap in the diagram.
Code
The snippet recomputes the correlated pair from its four chances, so the hand arithmetic above can be checked in one run.
import numpy as np
def joint_entropy(probs: np.ndarray) -> float: return float(-(probs * np.log2(probs)).sum()) # average surprise over pairs
p = np.array([0.4, 0.1, 0.1, 0.4]) # 00, 01, 10, 11h_joint = joint_entropy(p)print(round(h_joint, 3)) # -> 1.722print(round(h_joint - 1.0, 3)) # -> 0.722 conditionalJoint 1.722 minus the 1-bit margin leaves 0.722 conditional. Same margins as independence, but dependence moved the total.
Watch Out For
Summing marginal entropies for correlated features
Adding per-feature entropies double-counts shared bits. Above, the sum is 2.0 while the joint is 1.722, so a capacity budget built on the sum overbuys by 0.278 bits per pair.
Price bundles jointly or subtract the overlap. When features correlate strongly, treat the marginal sum as fiction.
Trusting plug-in entropy on small samples
Few samples hide rare pairs, so the plug-in estimate runs low. With 100 samples spread over 64 pairs, the downward bias is roughly 0.3 nats, about 0.45 bits, before any correction.
Smooth the counts, use a bias-corrected estimator, or collect more data. When many pairs are unseen, read the estimate as a floor rather than a value.
The Quick Version
- Joint entropy prices pairs by averaging surprise over joint outcomes.
- Conditional entropy prices the remainder after knowing one variable.
- The chain rule splits pairs additively: .
- Two independent fair coins total 2 bits; the correlated pair totals 1.722 bits with 0.278 bits of overlap.
- Conditioning never increases entropy, with equality exactly under independence.
- Never sum marginal entropies for correlated bundles, and never trust tiny-sample plug-in estimates at face value.