Back to the on-screen lesson ·
Why $H(X, Y) = H(X) + H(Y \mid X)$, how it extends to any number of variables, and how it finds whichever entropy is awkward to compute directly.
Paper packet. Every task here also exists on screen, where it is checked automatically; answers written on paper are not assessed by Nydus. When you are back at a device, enter your answers there.
By the end of this lesson you will be able to derive the chain rule $H(X, Y) = H(X) + H(Y \mid X)$ from the product rule for probabilities, rearrange it into each of its forms, extend it to several variables with one conditional term each, use it to find whichever entropy a problem leaves out, including the information a function of a variable forgets, and bracket a joint entropy when only the marginals are known.
Joint and conditional entropy from a table, and the product rule $p(x, y) = p(x)\,p(y \mid x)$ for probabilities. This lesson takes the logarithm of that product rule and averages it, and the result is the identity you will use more than any other in the course.
The chain rule is $H(X, Y) = H(X) + H(Y \mid X)$, and its extension adds one conditional term per variable. In the two-circle picture each conditional entropy is a crescent, the part of one circle outside the other. The information lost by a function is $H(X \mid f(X)) = H(X) - H(f(X))$, the residue of $X$ that $f$ forgets.
The chain rule $$H(X, Y) = H(X) + H(Y \mid X) = H(Y) + H(X \mid Y)$$ follows from $p(x, y) = p(x) p(y \mid x)$ by taking logarithms and averaging: describing the pair costs describing $X$, then describing $Y$ knowing $X$. It extends to any number of variables, $H(X_1, \ldots, X_n) = \sum_i H(X_i \mid X_1, \ldots, X_{i-1})$, and it is the workhorse for computing: whenever one term is awkward from the definition, compute the other two and subtract. Combined with conditioning reduces entropy it gives $H(X_1, \ldots, X_n) \le \sum_i H(X_i)$. Two consequences you will use constantly: $H(X \mid Y) = H(X, Y) - H(Y)$, and if $Y = f(X)$ then $H(X \mid f(X)) = H(X) - H(f(X))$, the information lost by applying $f$. The same rule for mutual information, $I(X; Y, Z) = I(X; Y) + I(X; Z \mid Y)$, appears in the next unit.
Another way: picture
Two overlapping circles, $H(X)$ on the left and $H(Y)$ on the right. The union is $H(X, Y)$; the right crescent outside the left circle is $H(Y \mid X)$. The chain rule says the union is the left circle plus that crescent.
Another way: steps
Six quantities describe a pair of variables, and the diagram keeps them straight: two circles, their union, the two crescents and the overlap. The chain rule is the statement that the union is a circle plus the other crescent.
| Quantity | noisy copy, $p = 0.1$ | region of the diagram |
|---|---|---|
| $H(X)$ | $1$ | left circle |
| $H(Y)$ | $1$ | right circle |
| $H(X, Y)$ | $1.469$ | union |
| $H(Y \mid X)$ | $0.469$ | right crescent |
| $H(X \mid Y)$ | $0.469$ | left crescent |
| $I(X; Y)$ | $0.531$ | overlap |
Any three of the six that are not all on one side of the picture determine the rest. The identities you will use most: $H(X, Y) = H(X) + H(Y \mid X)$, $H(Y \mid X) = H(X, Y) - H(X)$, and $H(X \mid Y) = H(X) - I(X; Y)$ once mutual information appears in lesson 5.
With three variables the rule peels them off one at a time: $$H(X, Y, Z) = H(X) + H(Y \mid X) + H(Z \mid X, Y),$$ and the order is yours to choose, since the joint entropy does not depend on it. Each conditional term is at most the unconditional one, so $H(X_1, \ldots, X_n) \le \sum_i H(X_i)$, with equality exactly when the variables are mutually independent. Here is the bookkeeping for a triple:
| Given | Step | Result |
|---|---|---|
| $H(X) = 2$, $H(Y \mid X) = 1$ | $H(X, Y) = H(X) + H(Y \mid X)$ | $3$ |
| $H(Z \mid X, Y) = 0.5$ | $H(X, Y, Z) = H(X, Y) + H(Z \mid X, Y)$ | $3.5$ |
| $H(Y) = 1.5$ | $H(X \mid Y) = H(X, Y) - H(Y)$ | $1.5$ |
| check | $H(X, Y, Z) \le H(X) + H(Y) + H(Z)$ | needs $H(Z) \ge 0$: fine |
Common mistakes
The first error is subtracting in the wrong order and getting a negative conditional entropy; $H(Y \mid X)$ is the joint entropy minus $H(X)$, and it can never be below $0$ or above $H(Y)$. The second is using $H(X \mid Y)$ where $H(Y \mid X)$ is wanted; the two crescents differ unless $H(X) = H(Y)$. The third, in the three-variable chain, is conditioning the last term on $Z$ alone or on one earlier variable; it is $H(Z \mid X, Y)$, given everything before it. And the rule is an identity, not an inequality: it never needs independence, which is only the special case where the conditional term equals the plain one.
$p(x, y) = p(x) p(y \mid x)$, so $-\log_2 p(x, y) = -\log_2 p(x) - \log_2 p(y \mid x)$.
Logarithm of a product.
Average both sides over $p(x, y)$: the left is $H(X, Y)$, the right is $H(X) + H(Y \mid X)$.
Expectation is linear.
$X$ uniform on $\{1, \ldots, 16\}$, $Y = X \bmod 4$: $H(X) = 4$, $H(Y) = 2$, and $H(X, Y) = H(X) = 4$ since $Y$ is a function of $X$.
Three quantities from the setup.
$H(X \mid Y) = H(X, Y) - H(Y) = 4 - 2 = 2$ bits: the residue leaves four equally likely candidates.
Chain rule the other way round.
$H(X, Y) = 5$ bits and $H(X) = 3$ bits.
Chain rule: $5 = 3 + H(Y \mid X)$.
$H(Y \mid X) = 2$ bits: after seeing $X$, two bits of $Y$ remain unexplained.
$H(Y)$ must be at least $2$, so if the problem gave $H(Y) = 1$ the data would be inconsistent.
$H(X) = 6$ bits; $Y = X \bmod 8$ is uniform on $8$ residues, $H(Y) = 3$.
$Y$ is a function of $X$, so $H(X, Y) = H(X) = 6$.
$H(X \mid Y) = H(X, Y) - H(Y) = 6 - 3 = 3$ bits: given the residue, $8$ values remain equally likely.
$H(Y \mid X) = 4 - 3 = 1$ bit.
$H(X \mid Y) = 4 - 2 = 2$ bits; both are below the unconditional entropies, as they must be.
Match each entropy to the expression the chain rule gives for it.
| $H(X) + H(Y \mid X)$ | $H(X, Y) - H(X)$ | $H(X, Y) - H(Y)$ | $H(X) + H(Y \mid X) + H(Z \mid X, Y)$ | $H(X) + H(Y) + H(Z)$ | |
|---|---|---|---|---|---|
| $H(X, Y)$ | |||||
| $H(Y \mid X)$ | |||||
| $H(X \mid Y)$ | |||||
| $H(X, Y, Z)$ |
Build the proof of the chain rule $H(X, Y) = H(X) + H(Y \mid X)$.
This task has no paper form; do it on a device.
$H(X) = 5$, $H(Y \mid X) = 3$ and $H(Y) = 4$ bits. Fill in $H(X, Y)$ and $H(X \mid Y)$.
| Bits | |
|---|---|
| $H(X, Y)$ | |
| $H(X \mid Y)$ |
$H(X) = 2$, $H(Y \mid X) = 1$ and $H(Z \mid X, Y) = 3$ bits. Fill in $H(X, Y)$ and $H(X, Y, Z)$.
H(X, Y) = p, H(X, Y, Z) = t
Two sensors on a machine produce readings $X$ and $Y$ with $H(X) = 2$ and $H(Y) = 3$ bits, and nothing is known about how they are related. Give the set of values that $H(X, Y)$, the entropy of one paired reading, can take, as an interval.
This task has no paper form; do it on a device.
Lesson test: one question per skill, one attempt each, no hints. Your answers are checked when you submit.
$X$ is uniform on $\{1, \ldots, 32\}$ and $Y = X \bmod 2$. What is $H(X \mid Y)$ in bits?
Answer:
You can move between joint, marginal and conditional entropies with the chain rule and extend it to any number of variables. Say in your own words what the last term of the three-variable chain rule is conditioned on, and why. This closes the unit on entropy; next comes relative entropy, the distance-like quantity behind Gibbs' inequality.
13. Your turn: $H(X) = 3$, $H(Y) = 2$, $H(X, Y) = 4$; find $H(Y \mid X)$ and $H(X \mid Y)$, step 2