Workbench / Information Theory Exercises
B1·10
Information Everywhere: Language, DNA, Randomness and Passwords
Exercises for chapter 10: models as upper bounds, blending contexts, bytes against information, why DNA looks random, min-entropy against Shannon entropy, and generators that look random but aren't, in your own words; min-entropy by hand, the bias of turning bytes into digits with "% 10", Shannon's guessing-game bounds tested on a source whose entropy is known, identifying languages by cross-entropy, password guessing measured honestly on a held-out half of 32.6 million accounts, a genome coded with its own reversed copy, and senior exercises on a token generator, a password policy, and a claim about "entropy" in a product.
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 chapters 1 to 10 together, what the chapter leaves out explains what it skips, and senior exercises put the ideas into designs and reviews. The programs import the chapter's real.py and read the chapter's data files.
Theory
T1. Models as upper bounds
Explain why a better language model can only ever lower our estimate of the entropy of English, never prove it's higher.
T2. Why blend?
Explain to someone who built chapter 7's order- models why blending orders beats choosing the best single order.
T3. Bytes aren't information
The chapter's 10,000 bytes of Japanese held 3,334 characters and compressed to 8.17 bits per character, English 2.80. Does that mean Japanese is "more informative"? Explain.
T4. Why DNA looks random
Explain why general-purpose compressors barely compress DNA, yet biologists say genomes are full of structure.
T5. Min-entropy
Explain why the strength of a secret should be measured by min-entropy rather than Shannon entropy, with an example.
T6. Random-looking isn't unpredictable
Explain the difference between a statistically good pseudorandom generator and a cryptographically secure one, using the lab's Mersenne Twister.
Practice and programs
P1. By hand
(a) A token is chosen from 1,000,000 values, but 1 % of the time a fixed default token is used. Find its min-entropy. (b) A password policy accepts any 6-digit PIN, and 2 % of users choose 123456. What's the min-entropy, and what fraction of accounts falls to one guess per account? (c) How many random words from a list of 2,048 give at least 80 bits? (d) The lab's blended model averages 2.13 bits per symbol on 27 symbols. What fraction of the maximum possible is that?
P2. Digits from bytes
A program makes numeric codes by taking random bytes modulo 10. Compute exactly how biased that is, what it does to the min-entropy of a 6-digit code, and compare with secrets.randbelow.
P3. Testing Shannon's bounds where the answer is known
Shannon's guessing-game bounds can't be checked on English, whose entropy is unknown. Build a random order-1 source over 6 symbols whose entropy rate can be computed exactly, and compare the upper and lower bounds for an ideal guesser and for a poor one.
P4. Which language is this?
Train blended order-3 models on 70 % of the declaration in eight languages that use the Latin alphabet, and identify the language of pieces of the remaining 30 % by which model is least surprised. How short can the pieces be?
Cumulative projects (chapters so far: 01–10)
C1. Guessing passwords honestly
The chapter's guess curve used the leak to guess its own passwords, an attacker's ideal. Split the accounts at random into two halves, build the attacker's list from half A and attack half B, and compare. Use chapter 3's binomial distribution and chapter 7's lesson about held-out data.
C2. Coding a genome with its own reverse complement
Code the chloroplast genome with an order-3 model, then find the stretches that copy, reversed and complemented, something earlier, and code each as a pointer instead. How much does it save? Use chapter 6's code lengths and chapter 7's conditional thinking.
What the chapter leaves out
Rényi entropies
Shannon entropy and min-entropy are two members of a family: the Rényi entropy of order , . Order 1 (as a limit) is Shannon's, order is min-entropy, and order 2, the "collision entropy", measures how likely two independent draws are to match. Each answers a different question about uncertainty; they agree only for uniform distributions.
Randomness extractors
A noise source with plenty of min-entropy but uneven bits (a biased, correlated physical process) can be turned into nearly uniform random bits by a randomness extractor, such as a hash function applied to a long sample. The leftover hash lemma (1989) says how many nearly uniform bits can be extracted: about the min-entropy, minus a margin for the required closeness. Operating systems and hardware generators use such conditioning.
Kolmogorov complexity
The chapter measures information with probabilities. Andrey Kolmogorov (1965), Ray Solomonoff and Gregory Chaitin measured the information in a single string as the length of the shortest program that prints it. The digits of have high entropy as a sequence of digits but tiny Kolmogorov complexity. It can't be computed in general, but compressors give upper bounds on it, which is the basis of "compression distance" methods for comparing texts and genomes.
Language model scaling
Neural language models' cross-entropy on text falls smoothly, roughly as a power law, with more parameters, data and computation (measured by Jared Kaplan and colleagues, 2020, and refined since). Where it levels off would be an estimate of the entropy rate of the text itself, the quantity Shannon estimated with people in 1951.
Senior exercises
S1. A token generator under review
A service generates password-reset tokens as str(random.randint(100000, 999999)), valid for 24 hours, with no limit on attempts. Review it.
S2. A password policy for a new product
Your product's current rule is "at least 8 characters, with an uppercase letter, a digit and a symbol, changed every 90 days". Propose a replacement and justify it with the chapter's numbers.
S3. "Military-grade entropy"
A vendor of a hardware security device claims "1,000 bits of entropy per second" from its noise source, measured by compressing the raw output and finding it incompressible. Assess the claim.