Information theory begins with a simple question: how much uncertainty is contained in a random variable? From that starting point, we can quantify how uncertainty changes when variables are observed, how different two probability distributions are, and how much information two variables share.
This note develops the core definitions and identities from Sections 2.1-2.5 of Cover and Thomas, using discrete random variables and base-2 logarithms throughout.
Notation convention
Uppercase letters such as , , and denote random variables. Lowercase letters such as , , and denote particular realized values. Calligraphic letters such as denote alphabets, so . We write , , and . When comparing two abstract distributions, we follow the book and use the shorter notation and .
1. Entropy
Let be a discrete random variable with alphabet and probability mass function . Before defining the average uncertainty of , it helps to quantify the information associated with one outcome.
1.1 Surprise of an outcome
The self-information or surprise of observing is
This definition captures three useful intuitions:
- A likely event is not very surprising.
- A rare event carries more information.
- Independent events should contribute additive information.
The third property explains the logarithm. If and are independent, then the joint probability of observing and is , while the information in that joint outcome is
Probability multiplies, but information adds.
1.2 Expected surprise
The entropy of is the expected surprise of its outcome:
We use the convention . Entropy depends only on the probabilities, not on the labels assigned to the outcomes.
Because , every term is nonnegative, so
If the logarithm uses base , entropy is measured in bits. Natural logarithms give nats. See the notation reference for the probability notation used throughout this note.
1.3 Bernoulli entropy
For ,
where denotes the entropy of a Bernoulli random variable with parameter .
- If or , then is deterministic and .
- If , both outcomes are equally likely and bit.
Figure 1: The binary entropy is symmetric around , where uncertainty is maximized.
Entropy therefore measures uncertainty rather than the numerical size of an outcome.
Unequal probabilities
Suppose has four possible outcomes with probabilities
Then
The terms , , and are the surprises of outcomes having probabilities , , and .
1.4 Entropy as description length
Entropy is closely connected to compression. If outcomes are encoded efficiently, common outcomes receive short binary descriptions and rare outcomes receive longer descriptions. The entropy is the fundamental target for the average number of bits required to describe the outcome.
2. Joint Entropy and Conditional Entropy
Entropy extends naturally from one random variable to several. For background on joint and conditional distributions, see Joint Probability Distributions.
2.1 Joint entropy
The pair can be treated as one vector-valued random variable. Its joint entropy is
Joint entropy measures how much uncertainty is present in the pair before either variable is observed.
2.2 Conditional entropy
After observing , our remaining uncertainty about is
The conditional entropy averages this quantity over :
The distinction is important:
- is the uncertainty after one particular observation.
- is the remaining uncertainty averaged over all possible observations of .
2.3 The two-variable entropy chain rule
Using the probability factorization
we obtain
Therefore,
The interpretation is sequential: first describe , then describe what remains unknown about once is available.
Reversing the order gives
In general, and are not equal. What is equal is the total joint uncertainty obtained after adding the appropriate marginal entropy.
Main properties of joint and conditional entropy
These properties hold for discrete random variables.
Joint entropy
Symmetry
Chain rule
Bounds
The upper bound is attained if and only if and are independent.
Repeating a variable adds no uncertainty
Conditional entropy
Average remaining uncertainty
Nonnegativity
Conditioning reduces entropy on average
with equality if and only if and are independent. A proof appears in the inequalities note.
Zero conditional entropy
if and only if is determined by with probability one.
Conditional entropy is generally not symmetric: need not equal .
3. Relative Entropy (KL Divergence)
Entropy describes uncertainty within one distribution. Relative entropy instead compares two distributions over the same alphabet :
- is the distribution that actually generates the outcomes.
- is the distribution used by our model, approximation, or code.
The question is: how costly is it to use when the data really follow ?
3.1 From the likelihood ratio to KL divergence
For one realized outcome , compare the probability assigned by the two distributions through the log-likelihood ratio
This quantity is positive when and negative when . However it is not a true distance between distributions since it is not symmetric and does not satisfy the triangle inequality. Nonetheless, it is often useful to think of relative entropy as a “distance” between distributions. Because outcomes are generated according to , we average the log-likelihood ratio under :
This expectation is the relative entropy or Kullback-Leibler divergence of relative to . With base-2 logarithms, it is measured in bits.
The order has meaning
In , samples come from , so determines how each log-ratio is weighted. Reversing the arguments changes both the ratios and the averaging distribution. The symbol is deliberately directional.
3.2 Coding interpretation: the cost of the wrong model
If we know the true distribution , the ideal description length assigned to outcome is
If we instead construct the code using , the same outcome receives length
Since outcomes still occur according to , the average length of the code based on is the cross-entropy
Adding and subtracting gives
Here is the entropy of the distribution . Therefore,
KL divergence is the extra average description length caused by using instead of the true distribution . If , there is no mismatch and the extra cost is zero.
Connection to cross-entropy loss
The same decomposition explains the cross-entropy loss used to train classifiers. Let be an input random variable and let be its class-label random variable with alphabet . Suppose
- is the true joint data distribution,
- is its conditional label distribution, and
- is the distribution predicted by a model with parameters .
For a fixed input realization , the population cross-entropy is
Averaging over inputs and applying the KL decomposition gives
The conditional entropy is determined by the data-generating distribution and does not depend on . Therefore, minimizing cross-entropy with respect to is equivalent to minimizing the expected KL divergence from the true conditional distribution to the model distribution.
In a labeled dataset, we observe one class realization for each input realization . Its one-hot target is . Machine-learning libraries normally use natural logarithms, so the per-example loss becomes
For binary classification, with and , this reduces to binary cross-entropy:
These empirical losses are measured in nats rather than bits. Changing the log base only rescales the objective by a positive constant and does not change its minimizer.
Worked example: Bernoulli distributions
Let and be Bernoulli PMFs with and , where the realization denotes success.
Figure 2: The bars show where and disagree. The curve shows the resulting : it reaches zero only when the model matches the true distribution, , and grows as the mismatch increases.
Contribution to Summing the two weighted contributions,
One outcome contributes a negative value, but the average is nonnegative. If we reverse the arguments,
because the expectation is now taken under . The two directions describe different modeling mistakes.
3.3 Conditional relative entropy
For joint PMFs and , the conditional relative entropy between and , averaged over , is
The notation does not explicitly mention the averaging distribution ; as in the book, it is understood from context.
3.4 What KL divergence does and does not guarantee
KL divergence satisfies
with equality if and only if for every . This nonnegativity is not obvious from the individual terms, as the example above shows; it is a property of their expectation.
Proof: KL divergence is nonnegative
Let . If for any , then , so the claim holds immediately. Otherwise, for every .
The elementary inequality
gives
Since , this implies
Equality in occurs only at . Therefore equality requires for every . Normalization then leaves no probability mass for outside , so for every . Hence
If some outcome satisfies but , then
The model declares an outcome impossible even though it can occur under the data-generating distribution, producing an infinite log-loss.
Finally, KL divergence is not a geometric distance. In general,
and KL divergence does not satisfy the triangle inequality.
This expected log-ratio viewpoint connects directly to maximum likelihood estimation and appears as a regularization term in variational autoencoders.
4. Mutual Information
Entropy measures uncertainty in one distribution, while KL divergence compares two distributions. Mutual information uses KL divergence to measure dependence between two variables:
Expanding the definition,
The product is the joint probability mass function we would have if and were independent. Mutual information therefore quantifies how distinguishable the actual joint distribution is from an independent one.
- If and are independent, and .
- If knowing reduces uncertainty about , then .
4.1 Mutual information as uncertainty reduction
Since ,
By symmetry,
Combining these expressions with the entropy chain rule gives the fundamental identities
Figure 3: A mnemonic for the relationships among marginal entropy, conditional entropy, joint entropy, and mutual information.
Consequently,
and a variable contains all of its own uncertainty:
The venn diagram is a useful illustration: is drawn as the overlap between and , while and are the non-overlapping parts. The algebraic identities above are the actual definitions; the diagram should not replace them.
Main properties of mutual information
For discrete random variables and ,
Equivalent entropy forms
Symmetry
Nonnegativity and independence
with equality if and only if and are independent.
Entropy bound
Thus, two variables cannot share more information than either variable contains.
Proof. Since discrete conditional entropy is nonnegative,
Therefore,
By symmetry,
Combining the two inequalities proves the bound. Equality with holds exactly when , so is determined by with probability one; the analogous condition holds for equality with . This argument is for discrete entropy, since conditional differential entropy need not be nonnegative.
Self-information
4.2 Conditional mutual information
The conditional mutual information between and given is
It measures how much observing reduces uncertainty about when is already known. In the expectation, uppercase , , and are random variables drawn jointly according to .
5. Chain Rules
Chain rules turn one complicated information quantity into a sequence of simpler contributions. The guiding question is:
If the variables are revealed one at a time, how much new uncertainty, information, or model mismatch appears at each step?
No independence assumption is required. Following Section 2.5 of Cover and Thomas, each rule below uses conditioning to avoid counting information that earlier variables have already explained.
5.1 Chain rule for entropy
Suppose we want to describe the entire tuple . We can describe first, then describe only the part of that remains uncertain after is known, and continue in this way. This gives
The first term is written separately because nothing has been revealed before . Every later term is conditional on all earlier variables.
For three variables, the rule reads
Why does this work? The joint PMF has the probability chain rule
Entropy averages the negative logarithm of this probability. The logarithm converts the product into a sum, so the probability factorization becomes an entropy decomposition.
The variables may be revealed in any order. The total joint entropy stays the same, although the individual conditional terms generally change with the order.
5.2 Chain rule for conditional entropy
Now suppose some side information is available before either or is revealed. We first measure the uncertainty left in given , and then the uncertainty left in after both and are known:
The identity can be checked by expressing conditional entropy as a difference of joint entropies:
For a longer sequence, keep in the conditioning set at every step:
The important point is that is known throughout the entire process. The conditioning set grows from to , then to , and so on. We are not repeatedly learning ; it is background information available from the beginning.
5.3 Chain rule for mutual information
Suppose several variables jointly tell us something about . The mutual-information chain rule attributes that information one variable at a time:
For two variables,
The first term measures what tells us about . The second does not count all information in again; it counts only what adds after is already known.
To see the decomposition algebraically, insert and subtract :
Repeating the same step yields the -variable formula. As with entropy, the individual contributions depend on the order of the , but their sum is always the total information .
5.4 Chain rule for relative entropy
Here we compare two joint models, and . Their total mismatch has two sources:
- The models may assign different probabilities to .
- Even after the same value of is given, their conditional models for may disagree.
Factor both joint PMFs into these two stages:
Substituting the factorizations into the log-ratio separates the two sources of mismatch:
Therefore,
The first term measures disagreement about the marginal distribution of . The second is the conditional relative entropy
so it averages the conditional mismatch over . In other words: first pay for using the wrong model of ; then, for each observed , pay the average additional cost of using the wrong conditional model of .
6. Summary
| Quantity | Definition | Interpretation |
|---|---|---|
| Entropy | Uncertainty in | |
| Joint entropy | Uncertainty in the pair | |
| Conditional entropy | Uncertainty left in after observing | |
| KL divergence | Penalty for using when reality follows | |
| Mutual information | Dependence, or shared information, between and |
The most important identities are
and
Together, these definitions provide the basic language used throughout information theory, coding, statistics, and machine learning.
In the next blog I will continue with very important Information Inequalities, Data Processing, and Fano’s Inequality, including Jensen’s inequality, the log-sum inequality, sufficient statistics, and limits on estimation error.
Reference
Thomas M. Cover and Joy A. Thomas. Elements of Information Theory, 2nd ed., Sections 2.1-2.5. Wiley, 2006.