Proof that Mutual Information Is Symmetric

The mutual information (MI) of two random variables quantifies how much information (in bits or nats) is obtained about one random variable by observing the other. I discuss MI and show it is symmetric.

The mutual information (MI) between two random variables captures how much information entropy is obtained about one random variable by observing the other. Since that definition does not specify which is the observed random variable, we might suspect this is a symmetric quantity. In fact, it is; and I claimed that without proof in my previous post. The goal of this post is to show why this definition is indeed symmetric. The proof will highlight a useful interpretation of MI.

Let XX and YY be continuous random variables with densities pX(x)p_X(x) and pY(y)p_Y(y) respectively. The MI of XX and YY is

MI(X,Y)=H[X]EY[H[XY=y]]=xpX(x)lnpX(x)dx+ypY(y)xpXY(x,y)lnpXY(x,y)dxdy=yxpX,Y(x,y)lnpX(x)dxdy+ypY(y)xpXY(x,y)lnpXY(x,y)dxdy=yxpX,Y(x,y)lnpX(x)dxdy+yxpX,Y(x,y)lnpXY(x,y)dxdy=yxpX,Y(x,y)(lnpXY(x,y)lnpX(x))dxdy=yxpX,Y(x,y)ln[pXY(x,y)pX(x)]dxdy=yxpX,Y(x,y)ln[pXY(x,y)pX(x)×pY(y)pY(y)]dxdy=yxpX,Y(x,y)ln[pX,Y(x,y)pX(x)pY(y)]dxdy=KL[pX,YpXpY].(1) \begin{aligned} \text{MI}(X, Y) &= \mathbb{H}[X] - \mathbb{E}_Y\left[ \mathbb{H}[X \mid Y = y]\right] \\ &= -\int_x p_X(x) \ln p_X(x) \text{d}x + \int_y p_Y(y) \int_x p_{X \mid Y}(x, y) \ln p_{X \mid Y}(x, y) \text{d}x \text{d}y \\ &= - \int_y \int_x p_{X, Y}(x, y) \ln p_X(x) \text{d}x \text{d}y + \int_y p_Y(y) \int_x p_{X \mid Y}(x, y) \ln p_{X \mid Y}(x, y) \text{d}x \text{d}y \\ &= - \int_y \int_x p_{X, Y}(x, y) \ln p_X(x) \text{d}x \text{d}y + \int_y \int_x p_{X, Y}(x, y) \ln p_{X \mid Y}(x, y) \text{d}x \text{d}y \\ &= \int_y \int_x p_{X, Y}(x, y) \Big( \ln p_{X \mid Y}(x, y) - \ln p_X(x) \Big) \text{d}x \text{d}y \\ &= \int_y \int_x p_{X, Y}(x, y) \ln \left[ \frac{p_{X \mid Y}(x, y)}{p_X(x)} \right] \text{d}x \text{d}y \\ &= \int_y \int_x p_{X, Y}(x, y) \ln \left[ \frac{p_{X \mid Y}(x, y)}{p_X(x)} \times \frac{p_Y(y)}{p_Y(y)} \right] \text{d}x \text{d}y \\ &= \int_y \int_x p_{X, Y}(x, y) \ln \left[ \frac{p_{X, Y}(x, y)}{p_X(x)p_Y(y)} \right] \text{d}x \text{d}y \\ &= \text{KL}[p_{X, Y} \lVert p_X \otimes p_Y]. \end{aligned} \tag{1}

In the last line of Eq. 11, “KL” refers to the KL divergence. Since the KL divergence is non-negative, mutual information is also non-negative. Furthermore, the mutual information is zero if and only if XX and YY are independent. This makes intuitive sense: if two random variables are independent, observing one tells you nothing about the other.

Finally, it’s pretty easy to see that we can simply reverse our calculations to get the mutual information of YY and XX:

MI(Y,X)=H[Y]EX[H[YX=x]]=ypY(y)lnpY(y)dy+xpX(x)ypYX(y,x)lnpYX(y,x)dydx=xypX,Y(x,y)lnpY(y)dydx+xpX(x)ypYX(y,x)lnpYX(y,x)dydx=xypX,Y(x,y)lnpY(y)dydx+xypX,Y(x,y)lnpYX(y,x)dydx=xypX,Y(x,y)(lnpYX(x,y)lnpY(y))dydx=xypX,Y(x,y)ln[pYX(x,y)pY(y)]dydx=xypX,Y(x,y)ln[pYX(x,y)pY(y)×pX(x)pX(x)]dydx=xypX,Y(x,y)ln[pX,Y(x,y)pX(x)pY(y)]dydx=KL[pX,YpXpY(y)].(2) \begin{aligned} \text{MI}(Y, X) &= \mathbb{H}[Y] - \mathbb{E}_X\left[ \mathbb{H}[Y \mid X = x]\right] \\ &= -\int_y p_Y(y)\ln p_Y(y) \text{d}y + \int_x p_X(x) \int_y p_{Y \mid X}(y, x) \ln p_{Y \mid X}(y, x) \text{d}y \text{d}x \\ &= -\int_x \int_y p_{X, Y}(x, y)\ln p_Y(y) \text{d}y \text{d}x + \int_x p_X(x) \int_y p_{Y \mid X}(y, x) \ln p_{Y \mid X}(y, x) \text{d}y \text{d}x \\ &= -\int_x \int_y p_{X, Y}(x, y)\ln p_Y(y) \text{d}y \text{d}x + \int_x \int_y p_{X, Y}(x, y) \ln p_{Y \mid X}(y, x) \text{d}y \text{d}x \\ &= \int_x \int_y p_{X, Y}(x, y) \Big( \ln p_{Y \mid X}(x, y) - \ln p_Y(y) \Big) \text{d}y \text{d}x \\ &= \int_x \int_y p_{X, Y}(x, y) \ln\left[\frac{p_{Y \mid X}(x, y)}{p_Y(y)}\right] \text{d}y \text{d}x \\ &= \int_x \int_y p_{X, Y}(x, y) \ln\left[\frac{p_{Y \mid X}(x, y)}{p_Y(y)} \times \frac{p_X(x)}{p_X(x)}\right] \text{d}y \text{d}x \\ &= \int_x \int_y p_{X, Y}(x, y) \ln\left[\frac{p_{X,Y}(x, y)}{p_X(x)p_Y(y)} \right] \text{d}y \text{d}x \\ &= \text{KL}[p_{X, Y} \lVert p_X \otimes p_Y(y)]. \end{aligned} \tag{2}

It’s easy to see that these derivations hold if XX and YY are both discrete. The tricky case is if XX is discrete and YY is continuous. Certainly, the derivations still work if we can interchange integrals and sums, which is true for finite sums. However, when the sums are infinite, we are effectively interchanging limits and integration. I don’t know enough measure theory to know when this is possible; but my very loose understanding is that the main value of Lebesgue integration is that it is easier to know when such regularity conditions hold.