Entropy

Entropy is the expected surprise of a random variable. A concentrated distribution has low entropy because outcomes are predictable; a uniform distribution has higher entropy because more outcomes remain plausible.

The bit interpretation comes from binary distinctions. One bit can answer one yes/no question, splitting the remaining possibilities into two groups. An event with probability carries one bit of surprise because one binary distinction can separate it from the alternatives. An event with probability carries two bits; an event with probability carries three bits. That pattern is exactly

Common outcomes have low surprise and can receive short codes. Rare outcomes have high surprise and need longer codes, but they also occur less often. Entropy averages this tradeoff over the source distribution. For individual symbols, real prefix codes have integer lengths; over long sequences, good codes can approach the entropy as an average number of bits per symbol.

Defining math

For a discrete distribution over outcomes ,

The convention is by limit. Base-2 logarithms measure bits; natural logarithms measure nats. Entropy is the baseline term in cross-entropy:

That identity explains why minimizing cross-entropy over is equivalent to minimizing KL divergence from the data distribution when is fixed.

Worked example

Imagine a three-symbol source where appears half the time and and each appear one quarter of the time. Seeing carries bit of surprise, while seeing either rarer symbol carries bits. The expected surprise is therefore bits.

If the same source were uniform over three symbols, every outcome would carry bits. Uniform entropy is higher because no symbol can be guessed more confidently than another; the skewed source is partly predictable before the next symbol arrives. In coding terms, the skewed source can use a shorter code for and longer codes for and , winning on average because appears more often. A uniform source offers no such shortcut.

Caveats

Entropy is not variance. Relabeling categories leaves entropy unchanged, and two distributions with very different practical consequences can have the same entropy. For dependence between variables, use mutual information, not marginal entropy alone.

References