Workbench / Information Theory Exercises
B1·01
Start Here: What Information Is
Exercises for chapter 1: information against meaning, why surprise must be a logarithm, rare and common outcomes, binary digits against bits of information, Shannon's system mapped onto real ones, units, a surprise calculator, the worst case of twenty questions for every size up to 2048, compressing biased bits, the information in Shakespeare's vocabulary and in everyday data, and senior exercises on logs that say nothing, sizing identifiers, and telemetry over a costly link.
Start here: how these exercises work
Write your answer in the box first; hints open one at a time as you write, and the solution a couple of minutes after the last hint. Theory is in your own words, practice and programs come with real output (Python 3.13), cumulative projects use every chapter so far (here, just chapter 1), what the chapter leaves out explains what it skips, and senior exercises put the ideas into designs and reviews. The programs that read text expect the chapter's data/shakespeare.txt beside them.
Theory
T1. Information is not meaning
Explain to a friend why, in information theory, "your train is on time" can carry less information than "your train is cancelled", even though both are equally meaningful. Then give an example of a message that's false but still carries information in Shannon's sense.
T2. Why a logarithm
In your own words, explain why the surprise of an outcome must be a logarithm of its probability, and not, say, or . Check your argument on two independent coin tosses.
T3. When "no" says almost nothing
A smoke alarm sounds on about 1 day in 1000 (mostly burnt toast). How much information is in "the alarm didn't sound today", and in "the alarm sounded"? What does this tell you about where the information in a stream of daily alarm reports is?
T4. When is a binary digit worth a bit?
A file stores binary digits. Under what conditions does each stored digit carry exactly one bit of information? Give one example where a digit carries less, and say how a compressor would notice.
T5. Shannon's picture of a video call
Map a video call between two phones onto Shannon's five boxes and the noise source. Then say which step removes redundancy and which adds it, and why it isn't wasteful to do both.
T6. Changing the base
Explain why measuring surprise with , or gives the same theory in different units. Convert 10 bits to nats and to bans, and say which unit a programmer, a physicist and Hartley would choose.
Practice and programs
P1. By hand
(a) What's the surprise of drawing a red card from a shuffled deck? A red king? (b) How many yes-or-no questions are always enough to find a chosen square on a chessboard? (c) An event has 0.25 bits of surprise; what's its probability? (d) Which carries more information: a letter chosen uniformly from 26, or a digit chosen uniformly from 10 followed by a fair coin toss?
P2. A surprise calculator that refuses nonsense
Write surprise(p) returning bits, rejecting probabilities outside . Use it on five card events, then test additivity on 100,000 random pairs of probabilities. What's the largest error, and where does it come from?
P3. The worst case of twenty questions, for every size
Write a program that, for every from 1 to 2048, plays the halving game against every secret from 1 to and records the most questions needed. Compare the result with for every .
P4. Compressing biased bits
Generate 200,000 bytes whose bits are independent and each 1 with probability , for . Compress each with lzma and report the compressed bits per stored bit. Compare with the average surprise per bit, .
Cumulative projects (chapters so far: 01)
C1. How much information is a word?
Find how many different words Shakespeare's plays use (lower-cased, letters only). How many bits pick one of them if all are equally likely? Compare that with spelling a word letter by letter from 26 letters plus an "end" mark. Then compute the surprise of a few words at their real frequencies. What does the gap between the numbers tell you?
C2. The information in everyday data
How many bits are needed, at minimum, for: a day of the year; a time of day to the second; a date and time to the second within a century; a 10-digit phone number; a 4-digit PIN; one of 8 billion people; a 24-bit colour? Then compare the minimum for a timestamp with the 19 characters of 2026-11-27T09:00:00 as text.
What the chapter leaves out
Semantic information
The chapter, following Shannon, leaves meaning out. Philosophers and logicians have tried to measure it: Yehoshua Bar-Hillel and Rudolf Carnap (1952) measured a statement's semantic information by how many possible states of the world it rules out, and later work asks how to treat false statements, which by that measure could be the most "informative" of all. None of these has become an engineering tool, but they explain why "information" in everyday speech (useful, true, relevant) differs from the bits in this book.
Algorithmic information
Shannon's measure needs probabilities. Andrey Kolmogorov, Ray Solomonoff and Gregory Chaitin (1960s) defined the information in a single string without them: its length in bits of the shortest program that prints it. A million zeros has a short program; a random string doesn't. Kolmogorov complexity can't be computed in general, but it connects to entropy (for typical outputs of a source they agree on average), and it's why compressors give upper bounds: a compressed file is a program, in a limited language, that prints the original.
Fisher information
Statisticians use a different "information": Ronald Fisher's (1925) measures how much a sample tells you about an unknown parameter, such as a coin's bias. It's about estimation, not communication, though the two meet in statistics and machine learning (the Cramér–Rao bound, and the geometry of probability distributions).
Quantum information
A quantum bit, or qubit, can be in a superposition of 0 and 1. Benjamin Schumacher (1995) proved a quantum version of Shannon's source coding theorem, and Holevo's theorem (1973) shows a qubit still can't carry more than one classical bit of retrievable information. Quantum information is a field of its own, built on this book's ideas.
Senior exercises
S1. A log that says nothing
A service writes a log line request N status=OK for every request; 99.9 % are OK, 0.08 % SLOW, 0.02 % ERROR. Measure, on a million simulated lines, the raw size, the compressed size, and the average information per status, and propose a logging design that keeps the information and drops the bulk. What would you lose?
S2. Sizing an identifier
A system will create up to 10 billion orders over its life. (a) How many binary digits does a sequential order number need? (b) As text in base 10, how many characters? In base 62 (letters and digits)? (c) Random 64-bit identifiers are proposed so that servers needn't coordinate. Is 64 bits "enough" because is far more than 10 billion? What question does chapter 1 not yet answer?
S3. Telemetry over a costly link
A soil sensor on a remote farm reports moisture as one of 256 levels every minute over a satellite link billed by the byte. The reading changes, by one level up or down, in about 1 minute in 50; otherwise it repeats. Estimate how many bits per minute the readings really carry, and propose an encoding that gets close. What risk does your encoding create, and how would you contain it?