Workbench / Information Theory Exercises
B1·07
Joint and Conditional Entropy, Mutual Information
Exercises for chapter 7: the chain rule, conditioning on average and in a single case, mutual information's symmetry, the data processing inequality, overfitting and Fano's inequality in your own words; the bias of mutual information estimated from data, mutual information against correlation, Fano's bound for two kinds of sensor, how far back in a text the information about the next letter reaches, a word model tested on unseen text, and senior exercises on a feature that's too good, releasing statistics, and alerts that say the same thing.
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 7 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 info.py.
Theory
T1. The chain rule in words
Explain the chain rule to someone who knows chapter 4's grouping property, using a pair of dice where is the second die and then where is the sum.
T2. On average, not every time
Explain why conditioning reduces entropy only on average, with an everyday example where a particular piece of information leaves you more uncertain than before.
T3. Why mutual information is symmetric
Explain why tells you exactly as much about as tells you about , even when clearly causes (rain causes wet streets).
T4. The data processing inequality in practice
A team trains a model on summary statistics of customer behaviour (weekly totals) instead of the raw event log, and later wants to predict something that depends on the time of day of purchases. Explain, with the data processing inequality, why no model on the summaries can do as well as one on the raw log, and what that means for data retention.
T5. Overfitting as an information problem
Explain why the lab's training estimate of the conditional entropy kept falling as the context grew, while the estimate on unseen text rose after four letters. What is the model "learning" with long contexts?
T6. Fano's inequality as a limit on accuracy
Explain in words why a large conditional entropy forces any guess of from to be wrong often, and why a small one doesn't guarantee a good guess is easy to find.
Practice and programs
P1. By hand
A joint distribution of (rows) and (columns) is: , , , . Find (a) and ; (b) ; (c) ; (d) .
P2. The bias of estimated mutual information
Estimate the mutual information of truly independent pairs from samples of 100, 1,000 and 10,000, for variables with 2, 10 and 50 values each, averaging 40 trials. Compare with the approximate bias .
P3. Mutual information against correlation
Compare correlation and mutual information for , , plus noise, independent of , and when (else ), with uniform on to , on 50,000 samples.
P4. Fano's bound for two kinds of sensor
For a sensor of 8 equally likely states that's right a fraction of the time, compute and the smallest error probability Fano's inequality allows, (a) when errors are spread over the 7 other states, and (b) when every error reports the next state. Compare with the error of the obvious guess ("trust the reading").
Cumulative projects (chapters so far: 01–07)
C1. How far back does the information reach?
In the plays reduced to 26 letters and a space, measure the mutual information between each symbol and the symbol positions before it, for to 8. How fast does it fall, and what does that say about building a context model?
C2. A word model tested honestly
Build a model of the plays' words that predicts each word from the one before, mixed with the word's overall frequency, . Train on 90 % and measure bits per word on the training text and on the unseen 10 %, for several weights . What's the best weight, and why isn't it 1?
What the chapter leaves out
Conditional mutual information and interaction
is the information and share once is known. It can be larger than (the chapter's coins: 0 without , 1 bit given the match) or smaller (two effects of a common cause: dependent until the cause is known). The difference , the "interaction information", can be positive or negative, which is why three-variable information diagrams are hard to read.
Sufficient statistics
A summary is sufficient for if : it keeps everything says about . The number of heads in 100 tosses is sufficient for the coin's bias; the order of the tosses adds nothing. Sufficiency, a central idea of statistics since Ronald Fisher (1922), is exactly the equality case of the data processing inequality.
Transfer entropy and directed information
Mutual information is symmetric, so it can't say which way influence flows. Directed information (James Massey, 1990) and transfer entropy (Thomas Schreiber, 2000) measure how much the past of one process helps predict another beyond its own past, an information-theoretic version of Granger causality, used in neuroscience and economics, with the usual caution that predicting isn't causing.
Continuous mutual information
For continuous variables, mutual information is defined with densities and, unlike differential entropy (chapter 4's exercises), it keeps all its good properties: it's never negative and doesn't depend on units. For two variables with a joint normal distribution and correlation , it's bits: here mutual information and correlation say the same thing, which is why the difference between them only shows for non-linear relationships.
Senior exercises
S1. A feature that's too good
A churn-prediction team finds a feature whose mutual information with the label "customer cancelled within 30 days" is 0.95 of the label's entropy. The model using it is nearly perfect in testing. What do you suspect, and how do you check?
S2. Releasing statistics about people
A public dashboard shows counts of patients by age band, postcode and condition, updated daily. A privacy reviewer worries about re-identification. Use the chapter's ideas to explain the risk and propose safeguards.
S3. Alerts that say the same thing
An on-call team receives two alerts, "high error rate" and "high latency", which usually fire together. Over a quarter, each fired on about 5 % of hours, and both together on 4 %. Measure how redundant they are, and recommend what to do.