ViewWiki

Lesson 2 of 5

Entropy.

About 20 minutes · 5 practice questions

A source's average surprise: how to work it out, why it peaks for a fair coin and falls to zero when the outcome is certain, and why random noise is full of information.

Step 1 of 5 · The average surprise

Step 1 of 5

The average surprise

A biased coin produces mostly small surprises, and now and then a big one. To know how much information it produces on average, per flip, weight each surprise by its chance. That average is called entropy, written HH⁠:

H=p⋅log⁡21p+(1−p)⋅log⁡211−pH = p \cdot \log_2 \frac{1}{p} + (1-p) \cdot \log_2 \frac{1}{1-p}⁠

It is the same weighted average you take in probability, like an expected value: each value times its chance. Chance of heads is fixed at 90%, and Measure and compress is at Coins. Work out the entropy yourself.

To the question

Step 2 of 5

The curve

Measure and compress is now at Entropy. The curve on the glass board is HH⁠ for every chance of heads from 0% to 100%, and the marker shows the current coin. The curve is a hump: it rises from both ends to a peak of exactly one bit in the middle.

Before you move anything, think about what will happen to the entropy if the bias flips.

To the question

Step 3 of 5

A certain coin

At both ends of the curve the coin is no longer really flipped: the outcome is known in advance. The tape still fills with bits, one per flip, but the length of a record is one thing, and what it tells you is another.

To the question

Step 4 of 5

In between

Between the fair coin and the certain one, the entropy falls slowly at first and fast at the end. A 75% coin still carries about four fifths of a bit per flip, and a 99% coin only about eight hundredths. For a coin to be really predictable, it has to be very biased.

To the question

Step 5 of 5

Random noise is full of information

High entropy means the next symbol is hard to guess. So a fair coin’s tape, which looks like a meaningless jumble of 0s and 1s, is exactly the tape with the most information per bit. That sounds backwards, but it is the definition: information is what you could not have guessed. Compressed and encrypted files look like noise for the same reason.

To the question

Still of the Information and entropy 3D scene
Interactive scene

Loading the interactive version…

Each step sets up the Scene for you, and a control marked “fixed” stays put for that step.

To the experiment

Practice · Calculate

Chance of heads is fixed at 90%. Heads carries 0.150.15⁠ bits of surprise, and tails 3.323.32⁠. What is the coin’s entropy, the average surprise per flip, in bits?

To the experiment

Practice · Predict, then look

The marker on the curve shows 0.470.47⁠ bits for a coin that lands heads 90% of the time. Now the bias flips: the coin will land heads in only 10% of flips, and tails in 90%. What will its entropy be?

To the experiment

Practice · Predict, then look

What will the entropy be when the coin always lands heads? Write a number in bits per flip, and then Chance of heads moves to 100%.

To the experiment

Practice · Reach the target

Change Chance of heads until the coin’s entropy is 0.810.81⁠ bits per flip, then press Check.

To the experiment

Practice · Choose

Two tapes of bits, the same length. Tape A looks completely random: about as many 0s as 1s, with no pattern at all. Tape B is almost all 1s. Which tape has the higher entropy per bit?