Summary
Entropy is the expected surprisal of a random variable. Conditional entropy is the uncertainty left after observing another variable. Mutual information is the reduction in uncertainty from that observation. Information gain applies the same reduction to a candidate decision-tree split.
These are population properties of chosen random variables. Finite samples, sparse joint tables, binning, learned representations, and confounding can distort their estimates. Mutual information measures association, not causation. Low predictive entropy does not imply that a model is correct or calibrated.
Discrete entropy and units
For a discrete random variable with probability mass function , entropy with logarithm base is
Use the convention . The surprisal of outcome is , so entropy is expected surprisal.
The logarithm base fixes the unit:
- Base 2 gives bits.
- Base gives nats.
- Base 10 gives hartleys, also called decimal digits of information.
Changing the base rescales the value:
Always state the base when reporting a number. An entropy value without a base has an unspecified unit.
A deterministic variable has entropy zero. If is uniform over outcomes, then
which is the largest entropy among distributions on that fixed support. Entropy depends on both probabilities and the variable definition. Relabeling outcomes preserves it, while merging outcomes can reduce it.
Coding interpretation
Suppose a source draws independent symbols from a known distribution . For binary prefix codes, the expected code length cannot be below . A Huffman code has expected length below bit per symbol.
Arithmetic coding works on sequences and can approach the entropy rate more closely. The claim concerns average length over source draws. It does not promise that every individual message has length .
Dependence changes the relevant rate. If each symbol depends on its history, a coder can use conditional probabilities. The chain rule gives
A code built for a wrong distribution has ideal expected length . Its excess over the entropy is the KL divergence from to , measured in the same log-base units.
Conditional entropy
Conditional entropy averages the remaining uncertainty in after observing :
The average over is required. One rare value of may determine , while common values leave substantial uncertainty.
The chain rule decomposes joint uncertainty:
For discrete variables, conditioning cannot increase entropy on average:
Equality holds when and are independent. Conditional entropy can be zero even when is random. This happens when determines exactly.
Mutual information in equivalent forms
Mutual information measures how much observing one variable reduces uncertainty about the other:
The chain rule gives several equivalent forms:
It is also an expected change from prior to posterior:
The KL form shows that mutual information is nonnegative. It is zero exactly when discrete and are independent. Although one entropy-reduction form starts with , mutual information is symmetric:
It has no causal direction. It is bounded by the uncertainty available in either variable:
Conditional mutual information
Conditional mutual information measures the additional association between and after is known:
It can vanish when explains a marginal association. It can also be positive when marginal mutual information is zero, as in interactions that cancel across groups. Conditioning on a common effect can create association, so conditional mutual information is not automatically a causal test.
This quantity helps measure the incremental value of a feature after other features are selected. Its empirical estimation is harder because each conditioning context receives fewer observations.
Three worked examples
Fair bit
Let . Then
Before observing the bit, one binary question is needed on average. A deterministic bit would have zero entropy.
Perfect copy
Let be a fair bit and let . Both marginal entropies are one bit, but . Therefore,
The joint entropy is one bit, not two, because the pair has only two possible values: and .
Binary noisy channel
Let be a fair bit, let be independent noise, and define . The output remains fair. The binary entropy function is
Given , the remaining uncertainty about is . Thus,
For , , so the channel carries about bits per input bit. At , the output is independent of the input and mutual information is zero.
Cross-entropy and KL divergence
For a true distribution and model distribution , cross-entropy is
Adding and subtracting gives
The first term is fixed when fitting to a fixed data distribution. Minimizing cross-entropy therefore minimizes forward KL divergence. If where , both cross-entropy and KL divergence are infinite.
This identity concerns expected log loss. A low empirical cross-entropy does not by itself prove good calibration under deployment shift or on poorly represented slices.
Information gain in decision trees
At a classification-tree node, let be the class label and let identify the child selected by a candidate split. Information gain is
under the node’s empirical distribution. The child entropies must be weighted by their sample counts.
If balanced binary labels become perfectly separated, the gain is one bit. If every child keeps the parent class proportions, the gain is zero.
Greedy trees choose the split with the largest estimated gain. Features with many possible split points can gain by chance. Minimum leaf sizes, pruning, held-out evaluation, and adjusted criteria help control this bias. Regression trees usually use variance or squared-error reduction instead of Shannon entropy.
Independence, symmetry, and processing
Mutual information detects any population dependence, including nonlinear dependence. Zero Pearson correlation does not imply zero mutual information. Zero mutual information does imply independence when the distributions are well defined.
For a Markov chain , the data processing inequality states
Processing without new access to cannot create information about . In particular, for a deterministic function ,
Equality can hold when retains all information about , as with an invertible transformation. A task-focused representation may discard nuisance information while retaining label information. The inequality does not require every useful representation to preserve every detail.
Continuous variables need different care
For a continuous variable with density , differential entropy is
Differential entropy can be negative. It also changes with measurement scale. For nonzero scalar ,
A value measured in meters therefore has a different differential entropy after conversion to centimeters. Discrete entropy does not have this coordinate dependence.
Continuous mutual information remains a KL divergence between the joint density and product of marginals. It is nonnegative and invariant under suitable invertible reparameterizations. A perfect continuous copy often has infinite mutual information because its joint distribution lies on a lower-dimensional set.
Binning a continuous variable creates a discrete variable whose entropy depends on bin width. Finer bins can keep increasing discrete entropy. State whether a result uses differential entropy, quantization, or a continuous mutual-information estimator.
Estimation from finite data
For discrete observations, the plug-in estimator replaces probabilities with frequencies:
It is usually biased downward because unobserved outcomes receive no mass. With observed categories, the Miller-Madow correction adds approximately
Plug-in mutual information is often biased upward under independence. A flexible joint table fits accidental dependence. Under regular large-sample conditions, the leading null bias is approximately
These approximations fail when counts are sparse. High-dimensional joint supports grow rapidly, so most configurations may never appear. More dimensions can make a direct frequency table unusable even with thousands of samples.
Continuous estimators use bins, kernels, nearest neighbors, density ratios, or learned critics. Each choice adds assumptions and tuning. Results can change with scaling, neighborhood size, architecture, and negative sampling.
Report the estimator, log base, sample size, preprocessing, and tuning choices. Use permutation tests to measure spurious dependence under a null. Use resampling or repeated datasets for uncertainty. A bootstrap measures sample variation, but it cannot restore unseen support or remove structural estimator bias.
Feature selection does not establish causation
Mutual information can rank features that have nonlinear association with a target. Compute the ranking inside each training fold. Selecting features on the full dataset leaks target information into evaluation.
High marginal mutual information can come from a confounder, a target-derived field, or a logging policy. It does not show that intervening on the feature changes the target.
Marginal ranking also misses redundancy and synergy. Two copies of one feature can each score highly while adding little together. For with independent fair bits, each input alone has zero mutual information with , while the pair determines .
Conditional mutual information can ask what a feature adds after a selected set. It is harder to estimate because the conditioning space is larger. Validate the final feature set on held-out data and inspect its provenance.
InfoNCE and representation learning
Contrastive learning often trains a critic to identify one positive pair among candidates. Under the standard construction, the positive comes from the joint distribution and the other candidates come independently from the marginal distribution.
With natural logarithms, the expected InfoNCE loss has the form
Under those sampling assumptions,
This gives lower-bound intuition for contrastive objectives. The bound is capped by and can be loose. A lower loss shows that the critic distinguishes positives from the sampled alternatives. It does not prove that the representation preserves every downstream factor.
In-batch negatives may be correlated or contain semantically valid matches. False negatives and sampling shortcuts through source, position, or formatting can loosen the bound’s practical interpretation. Treat InfoNCE as a training objective with a population interpretation under assumptions, rather than an exact mutual-information meter.
Predictive entropy, calibration, and confidence
Predictive entropy describes the spread of a model’s predicted distribution. A wrong model can assign 0.999 probability to one class and have very low entropy. A high-entropy prediction can reflect real ambiguity, missing features, or model failure.
Calibration asks whether events predicted with probability occur about fraction of the time. Expected cross-entropy is a proper scoring rule, but finite training, misspecification, regularization, selection, and distribution shift can leave a model miscalibrated.
Do not report entropy as a confidence interval. Attach sampling uncertainty to estimated information quantities. When using ensemble disagreement or parameter-label mutual information, state that the result depends on the model class and posterior approximation.
Interview procedure
Use this order:
- Name the variables and whether they are discrete or continuous.
- Define entropy as expected surprisal and state the log base.
- Define conditional entropy and give the chain rule.
- Derive mutual information in entropy and KL forms.
- State symmetry, independence, bounds, and data processing.
- Check a fair bit, a perfect copy, and an independent channel.
- Connect information gain to weighted tree splits.
- Discuss estimator bias, dimensionality, causation, and calibration.
If the interviewer changes an assumption, recompute the marginals before reusing a memorized formula.
Common mistakes
- Reporting entropy without a log base or unit.
- Forgetting to weight child entropy in a tree split.
- Calling mutual information directional because one formula uses conditional entropy.
- Claiming high mutual information proves a causal effect.
- Treating empirical zero correlation as independence.
- Applying discrete entropy intuition directly to differential entropy.
- Calling an InfoNCE value the exact mutual information.
- Ignoring upward bias in empirical mutual information.
- Reading low predictive entropy as calibrated confidence.
- Adding information from correlated observations as if they were independent.
Changed-assumption practice
Start with the fair binary channel where .
- Set . The output becomes independent of the input, so mutual information falls to zero.
- Set . The mutual information returns to about bits. Flipping the output converts it into a channel with error .
- Change the prior to . Now . The mutual information is bits, which is below the fair-input value.
- Replace with a constant. All information is discarded, so . Replacing with its inverse preserves mutual information.
- Observe two noisy copies. Information increases but cannot exceed bit. Do not add the two single-channel values because the outputs are dependent through .
- Give a tree feature a unique value per row. Training information gain can rise through memorization. Evaluate the split on fresh data or constrain leaf size.
For each change, identify which equality or assumption stopped applying before calculating.