Part I · Chapter 1

Twenty Questions and the Bit

A friend thinks of something. You may ask only yes-or-no questions. How many do you need, and which questions are worth asking? Out of that parlour game comes the unit every phone, hard drive and satellite link is measured in: the bit.

Play twenty questions with a clever child and you will notice something. They never open with "Is it a giraffe?" They ask "Is it alive?" or "Is it bigger than a breadbox?" A question about one particular thing almost always gets a "no", and a "no" you were expecting teaches you very little. A question that splits the remaining possibilities into two equal piles teaches you the most, whichever way the answer goes.

That instinct is the whole starting point of information theory. In this chapter we turn it into a number. By the end you will be able to say, for any event, how many yes-or-no questions' worth of news it carries, and why a rare event carries more than a common one.

If you have read Signals, Noise & Surprise in the cybernetics book, you met this idea in a sentence: information is uncertainty that disappears. Here we slow down and learn to measure it.

The best question cuts the pile in half

Below is a grid of possibilities. One of them is the secret. Click any square to hide the secret there (you know where it is; the guesser does not). Then let the guesser work, either with halving questions ("Is it in the outlined half?") or with one-at-a-time questions ("Is it this one?"). Watch two things: how many squares are still possible, and how full the information bar gets.

Interactive 1.1The Halving Guesser
Click a square to hide the secret, then ask questions
still possible information gained, and the group just asked about total uncertainty at the start (log₂ N bits)
64
 
With halving questions, every answer is worth about one bit, and 64 possibilities fall in exactly 6 questions. With one-at-a-time questions, each "no" is worth only a sliver of a bit; you may need dozens of questions. Try N = 100: halving now needs 6 or 7 questions, because 100 is not a power of two and some splits are uneven.

Count it out. One perfectly balanced question can tell apart 2 possibilities. Two questions can tell apart 4. Three can manage 8, ten can manage 1,024, and twenty can manage 1,048,576. Every extra question doubles how many things you can distinguish. That is why twenty questions is a fair game: a million or so things is roughly the size of the everyday world a friend is likely to think of.

Turn it around and you get a way to measure uncertainty. Faced with N equally likely possibilities, the number of balanced yes-or-no questions you need is the number of times you must halve N to reach 1. Mathematicians call that number the base-2 logarithm, written log₂ N. For 8 it is 3, for 64 it is 6, for a million it is about 20. For 100 it is about 6.64: not a whole number, because 100 does not halve cleanly, but still a perfectly good measure of how much uncertainty you start with.

The bit

One bit is the information you gain from the answer to a yes-or-no question whose two answers were equally likely.

Notice what the readout says when you ask a one-at-a-time question and hear "no". With 64 squares left, a "no" removes one of them: the uncertainty drops from log₂ 64 = 6 bits to log₂ 63 ≈ 5.977 bits. You learned about 0.02 of a bit. And when the guesser finally hits the right square, that single "yes" suddenly delivers several bits at once. A question whose answer you can predict is a weak question.

A bit of information is not a binary digit

The word "bit" does two jobs, and it pays to separate them once, right now.

A binary digit carries a full bit of information on average only when, beforehand, a 0 and a 1 were equally likely. Picture a sensor that sends one binary digit every second, but has sent 1 every second for a year. Each new digit still occupies a slot, yet it tells you almost nothing: close to zero bits. Much of this book is about the gap between the two meanings. Compression (Part II) packs information so that each stored digit carries nearly a full bit. Error correction (Part III) deliberately adds digits that carry no new information, because they protect the ones that do.

For how computers count with binary digits in the first place, see Counting by Doubling in the computer science book. Here we care about what those digits tell you.

Surprise: why rare events say more

So far every possibility was equally likely. Real life is lopsided. "The sun came up this morning" is almost certain; "a meteor landed in the garden" is not. Hearing the first news barely changes what you believed. Hearing the second changes a lot.

Here is the trick for measuring lopsided news. Suppose an event had probability 1/8. Learning that it happened narrows the world to a slice one-eighth the size, exactly as much narrowing as three balanced yes-or-no answers would give. So we say it carries 3 bits of surprise. An event with probability 1/2 carries 1 bit. An event with probability 1/1,024 carries 10 bits. An event that was certain (probability 1) carries 0 bits: you learned nothing you did not already know.

Interactive 1.2The Surprise Meter
Slide the probability, or pick an event
probability of the event (shaded area of the square) surprise in bits, and the matching run of heads
1 in 52
 
Each amber cut halves the square. The number of cuts needed to shrink it down to the event's slice is the surprise. Drawing the ace of spades (1 in 52) is about as surprising as 5.7 heads in a row; a 99%-likely event carries only about 0.015 bits.

The slide rule behind the meter is the logarithm again. Halving the square k times leaves a slice of size 1/2k; to reach a slice of size p you need log₂(1/p) halvings. That gives the single most important formula in this book, which we will now say once and then mostly use through pictures.

surprise(x) = log₂( 1 / p(x) ) bits "The surprise of an outcome is the number of times you would have to halve the possibilities to get down to something as unlikely as it."

We will always use base 2, so that the unit is the bit and one fair coin flip is worth exactly 1. (Other bases give other units, the way metres and feet measure the same length; base 2 is the natural choice when the answers are yes and no.) Information theorists call this quantity the self-information of the outcome. We will keep calling it surprise, because that is what it feels like.

Rare means informative

Halve the probability and you add exactly one bit of surprise. That is why a rare event carries more information: there were many more ways the world could have gone instead.

Why a logarithm? Because surprises should add

Why not just use 1/p itself as the measure? Try two independent events: a coin landing heads (1/2) and a die showing a six (1/6). The chance of both is 1/2 × 1/6 = 1/12. Probabilities of independent events multiply. But news should add: hearing two unrelated facts should tell you the sum of what each would tell you alone. The logarithm is exactly the tool that turns multiplying into adding. 1 bit for the coin plus 2.585 bits for the die gives 3.585 bits, which is log₂ 12.

Interactive 1.3Surprises Add
Change the dice, then roll
the outcome's share of all possibilities surprise of each die, and of both together
2
6
 
The pair lands in one cell out of (faces 1) × (faces 2). Its probability is the product of the two probabilities, yet its bar is exactly as long as the two amber bars laid end to end. A "die" with 2 faces is a coin.

Information is not meaning

One more warning before we go on. The surprise of a message depends only on how likely it was among the messages that could have been sent. It does not depend on what the message means, whether it is true, or how much it matters to you. A "yes" that was as likely as a "no" carries one bit whether the question was "Did you buy milk?" or "Will you marry me?".

This was a deliberate choice. Claude Shannon, in his 1948 paper A Mathematical Theory of Communication, set the meaning of messages aside explicitly: the engineer's job is to get the chosen message across, whichever one it is. That narrowing is what made the theory precise enough to build telephones, modems and storage on. Meaning has not gone away; it is simply a different question from the one this book answers.

Intuition Check

Which piece of news carries more information: "the fair die you rolled shows a six", or "the fair coin you flipped landed heads twice in a row"?

Intuition Check

A door sensor sends one binary digit every second: 1 for "closed", 0 for "open". The door is almost always closed. Roughly how much information does a typical digit from it carry?

Connections

What you now see

  • A balanced yes-or-no question halves the possibilities; N equally likely options need about log₂ N such questions.
  • One bit is the information in an answer whose two values were equally likely. A binary digit is a slot; it carries a full bit on average only when both values were equally likely (a single rare value can still carry many bits of surprise).
  • The surprise of an outcome with probability p is log₂(1/p) bits: halve the probability, add one bit.
  • For independent events probabilities multiply while surprises add, which is why the logarithm is the right measure.
  • Information measures unlikeliness, not meaning or importance.