Part III — Probability, Information Theory & Bayesian Inference · Chapter 8

Information & entropy

Hook

Which is more surprising: a coin that's fair, or one that always lands heads?

Intuition
25%A25%B25%C25%D

Drag the bars from equal toward one outcome dominating. Once an outcome becomes almost certain, there's really nothing left to learn from watching the next draw — you already knew what was coming.

Formalize

That "amount left to learn" is entropy, measured in bits —

H(X)=iP(xi)log2P(xi)H(X) = -\sum_i P(x_i) \log_2 P(x_i)
  • H(X)H(X) — the entropy of the distribution, in bits.
  • P(xi)P(x_i) — the probability of outcome xix_i.
  • xix_i — one specific outcome, indexed by ii.
  1. Zero when certain

    It's exactly zero when one outcome is certain.

  2. Maximal when uniform

    It's largest exactly when every outcome is equally likely — uncertainty is maximized when you have the least information to favor any one outcome.

Play
25%A25%B25%C25%D
H(X) = 2.00 bits

Drag toward uniform and watch entropy climb to its ceiling; drag toward certainty and watch it collapse toward zero.

Worked example

With P=(0.5,0.25,0.125,0.125)P = (0.5, 0.25, 0.125, 0.125):

  1. Compute each term, -p log₂ p
    • 0.5(1)=0.50.5(1) = 0.5
    • 0.25(2)=0.50.25(2) = 0.5
    • 0.125(3)=0.3750.125(3) = 0.375
    • 0.125(3)=0.3750.125(3) = 0.375

    Here the probabilities are all powers of two, so every term comes out to a whole number of bits.

  2. Add them up for the entropy
    H(X)=0.5+0.5+0.375+0.375=1.75 bitsH(X) = 0.5+0.5+0.375+0.375 = 1.75 \text{ bits}
Checkpoint

Reshape the distribution until H(X) reads (approximately) 1.5 bits — down from the uniform maximum of 2.

25%A25%B25%C25%D
H(X) = 2.00 bits
Drag a bar to try it
Summary
H(X)=iP(xi)log2P(xi)H(X) = -\sum_i P(x_i) \log_2 P(x_i)

Entropy measures how much uncertainty a distribution holds, in bits — zero at certainty, maximal at uniform. This exact quantity — how much uncertainty a split removes — is what a decision tree maximizes when it picks where to split, several chapters from now.