Entropy & Mutual Information

Entropy measures average uncertainty in a probability distribution; conditional entropy measures what remains after observation; mutual information measures the expected reduction. These quantities concern statistical dependence and coding limits, not meaning, truth or usefulness by themselves.

Information theory begins with uncertainty over possible messages, not with their semantic meaning. If a discrete random variable XX has outcomes xx with probabilities p(x)p(x), its entropy in bits is

H(X)=−∑xp(x)log⁡2p(x).H(X)=-\sum_x p(x)\log_2 p(x).

The contribution −log⁡2p(x)-\log_2 p(x) is the self-information of observing xx: a rare outcome is more surprising than a common one. Entropy is its expectation.

Why the logarithm appears #

Independent events should add information. If events with probabilities pp and qq occur independently, their joint probability is pqpq. The logarithm is the continuous transformation satisfying

−log⁡(pq)=−log⁡p−log⁡q.-\log(pq)=-\log p-\log q.

Changing log base changes units: base 2 gives bits, base ee nats. The minus sign makes information nonnegative because probabilities do not exceed one.

Entropy is zero when one outcome is certain. For nn equiprobable outcomes it is log⁡2n\log_2 n, the maximum possible entropy on that finite alphabet.

Worked example #

Let XX take values normal, slow, failed with probabilities 0.750.75, 0.200.20, 0.050.05:

H(X)=−(0.75log⁡20.75+0.20log⁡20.20+0.05log⁡20.05)≈0.99 bits.H(X)=-(0.75\log_2 0.75+0.20\log_2 0.20+0.05\log_2 0.05) \approx0.99\ \text{bits}.

There are three labels, but uncertainty is below log⁡23≈1.585\log_2 3\approx1.585 bits because one label dominates. Entropy does not say whether “failed” is important; it only describes the distribution.

Joint and conditional entropy #

For variables XX and YY,

H(X,Y)=−∑x,yp(x,y)log⁡2p(x,y).H(X,Y)=-\sum_{x,y}p(x,y)\log_2p(x,y).

Conditional entropy is

H(X∣Y)=∑yp(y)H(X∣Y=y).H(X\mid Y)=\sum_y p(y)H(X\mid Y=y).

The chain rule follows by factoring p(x,y)=p(y)p(x∣y)p(x,y)=p(y)p(x\mid y):

H(X,Y)=H(Y)+H(X∣Y).H(X,Y)=H(Y)+H(X\mid Y).

It says the average description of the pair can be separated into the information needed for YY plus what remains for XX after YY is known.

Mutual information #

Mutual information is the expected reduction in uncertainty about one variable after observing the other:

I(X;Y)=H(X)−H(X∣Y)=H(Y)−H(Y∣X).I(X;Y)=H(X)-H(X\mid Y)=H(Y)-H(Y\mid X).

Equivalently,

I(X;Y)=∑x,yp(x,y)log⁡2p(x,y)p(x)p(y).I(X;Y)=\sum_{x,y}p(x,y)\log_2\frac{p(x,y)}{p(x)p(y)}.

This is zero exactly when XX and YY are independent. It is symmetric and nonnegative. A perfect copy has I(X;Y)=H(X)I(X;Y)=H(X).

Mutual information detects nonlinear statistical dependence that zero correlation can miss. It still does not establish causality: a common cause, selection effect or data leakage can produce high I(X;Y)I(X;Y).

KL divergence and cross-entropy #

For distributions pp and qq on the same support,

DKL(p∥q)=∑xp(x)log⁡p(x)q(x)≥0.D_{KL}(p\|q)=\sum_x p(x)\log\frac{p(x)}{q(x)}\ge0.

It is an expected excess log loss from using qq when data follow pp. It is not symmetric and is not a distance. If q(x)=0q(x)=0 where p(x)>0p(x)>0, the divergence is infinite.

Cross-entropy is

H(p,q)=−∑xp(x)log⁡q(x)=H(p)+DKL(p∥q).H(p,q)=-\sum_x p(x)\log q(x)=H(p)+D_{KL}(p\|q).

When pp is fixed, minimizing cross-entropy over qq minimizes KL divergence. This identity is the foundation for many probabilistic learning losses.

Mutual information is itself a KL divergence:

I(X;Y)=DKL ⁣(p(x,y) ∥ p(x)p(y)).I(X;Y)=D_{KL}\!\left(p(x,y)\,\|\,p(x)p(y)\right).

It measures how far the joint distribution is from independence.

Continuous variables require care #

Replacing the sum with an integral yields differential entropy

h(X)=−∫p(x)log⁡p(x) dx.h(X)=-\int p(x)\log p(x)\,dx.

Unlike discrete entropy, h(X)h(X) depends on coordinate scale and can be negative. It is not the number of bits needed to encode an exact real value. Mutual information and relative entropy remain coordinate-invariant under suitable invertible transformations, which is why they are usually safer continuous quantities.

Estimation is the hard part #

Plugging empirical frequencies into the formulas works for small, well-sampled discrete alphabets. With many categories or continuous/high-dimensional variables, estimates can be strongly biased and sensitive to binning, kernels or model choice. Always report estimator, sample size, smoothing, uncertainty and validation.

What entropy does not measure #

  • semantic meaning or truth;
  • practical value of a message;
  • causal influence;
  • algorithmic complexity of one individual object;
  • thermodynamic entropy without a physical mapping and units;
  • security merely because output entropy looks large.

Entropy answers a precise probabilistic question. Its power comes from keeping that question precise rather than treating “information” as one universal substance.

Sources

  1. bookTheory of Systems and Systems Analysis: Lecture Coursepdfnotes
  2. paperClaude E. Shannon — A Mathematical Theory of Communication

Searches titles, aliases, headings, summaries, and full text.↑↓ move ↵ open esc close