Probability and Information
Eleven modules, from counting and Bayes' theorem to entropy, coding, channel capacity, the central limit theorem and Markov chains. Drag the figures, run the simulations, watch a Huffman code being built, work through an example one step at a time, then check yourself with concept questions and practice problems.
Follows the chapter order of D. Applebaum, Probability and Information: An Integrated Approach, 2nd ed. (Cambridge University Press, 2008), and covers Chapters 2–10; Chapter 1 is the book's introduction and has no module. Chapter and exercise numbers refer to that book; the questions and examples here are written for this page. Logarithms are to base 2 throughout, so information is measured in bits.
Counting selections
Before probabilities come counts. Choosing things from can be done in four ways, depending on whether order matters and whether repeats are allowed. Each gives a different formula, and the formulas are related by simple overcounting factors that you can see by listing every selection.
The idea
Applied to choosing objects from distinct ones:
The third comes from the second: every unordered selection of different objects can be put in order in ways, so the ordered count is times too big. The fourth is "stars and bars": a selection with repeats is a row of stars split into groups by bars, and we choose which of the positions are stars.
Explore
Worked example
A committee of 4 is chosen from 6 mathematicians and 5 physicists.
How many committees are possible with no restriction?
Order doesn't matter and nobody is chosen twice: .
How many have exactly two of each subject?
Choose the mathematicians, then the physicists, and multiply: .
How many contain at least one physicist?
Count the complement. The committees with no physicist are the all-mathematician ones, so the answer is . (Adding up the cases "exactly 1, 2, 3, 4 physicists" gives too.)
Now the committee also needs a chair and a secretary, two different members. How many ways are there to form the committee and fill both posts?
Two ways to count, which must agree. Pick the committee (330 ways), then the chair (4) and the secretary (3): . Or pick the chair (11), the secretary (10), then the other two members from the remaining nine: .
Check your understanding
In how many ways can 3 identical balls be placed in 4 different boxes, if a box may hold any number of balls?
- That counts the balls as distinguishable: it records which ball went where. Here only how many balls each box gets matters.
- That forbids two balls in the same box. Boxes may hold several balls.
- That is an ordered selection without repeats.
In the explorer, set and "ordered, no repeats". The 60 arrangements fall into colour blocks. What are the blocks?
- 6 blocks of 10The other way round. A block is one set of 3 objects; how many orders does such a set have?
- 10 blocks of 6
- 20 blocks of 3Three objects can be ordered in more than 3 ways.
Given and , what is ?
- You used the recursion once. , and still has to be reduced.
- That is : one step too many.
- It is undefined: makes no sense.The factorial is only defined for integers, but the gamma function is defined for every .
Practice
Rearranging a wordMultinomial coefficients
How many different strings can be made by rearranging all the letters of BANANAS? In how many of them are the three A's next to each other?
Hint
Swapping two equal letters gives the same string. For the second part, glue AAA into a single block.
Solution
There are 7 letters: A three times, N twice, B and S once. The count is . With AAA as one block there are 5 items, B, S, N, N and the block, so strings.
A sum of squaresCounting one thing two ways
Show that by counting something in two ways.
Hint
A group has women and men. Count the ways to choose people from it, sorted by how many women are chosen. Use .
Solution
Choosing of the people can be done in ways. Alternatively, choose women and men, in ways, and add over . Both count the same selections.
More practice: Applebaum, Exercises 2.7, 2.11 and 2.16.
Sets and measures
A probability is a special kind of measure: a rule that gives each set a size, so that the sizes of non-overlapping pieces add up. Everything else, from the complement rule to inclusion–exclusion, follows from that one property. Below, the measure of a region is its share of the rectangle's area.
The idea
Examples: the counting measure on a finite set, length on unions of intervals, area in the plane. From additivity alone:
- , and implies .
- , since is the disjoint union of and .
- If partition , then .
Explore
Worked example
Use the counting measure on . Let , , be the multiples of 2, 3 and 5 in .
Find , , .
, , .
Find the sizes of all the intersections.
A number is in exactly when it is a multiple of 6, so . Similarly (multiples of 10), (multiples of 15) and (just 30).
How many numbers in are divisible by at least one of 2, 3, 5?
By inclusion–exclusion, . Check: the numbers coprime to 30 are 1, 7, 11, 13, 17, 19, 23, 29, which is 8 numbers, and .
How many are divisible by exactly one of them?
In the sum , a number in exactly two sets is counted twice and the number in all three is counted three times. In the pairwise sum , a number in exactly two sets is counted once and the triple point three times. So
Check directly: 15 multiples of 2, minus those also divisible by 3 or 5 () leaves 8; for 3 it is ; for 5 it is . Total .
Check your understanding
is a probability measure with and . Which values can take?
- Only That assumes and don't overlap. Drag the discs on top of each other and watch .
- Any value in , so monotonicity forces .
- Any value in
- Any value in Inclusion–exclusion gives .
Which condition guarantees ?
- None; it always holds.Drag so that it sticks out of , and compare with .
- and are disjoint.Then , so , not (unless ).
On the subsets of a finite set, define . Is a measure?
- Yes: it is never negative.Non-negativity is only half of the definition. Check additivity on two disjoint one-point sets.
- Yes: it is built from the counting measure, which is a measure.A function of a measure need not be a measure. Test it on disjoint sets.
- No: additivity fails.
Practice
Proving inclusion–exclusionFrom additivity alone
Using only additivity on disjoint sets, prove for any .
Hint
Split into three disjoint pieces: , , .
Solution
Write , , . Additivity gives , and . So both sides equal .
A lower bound for an intersectionBonferroni's inequality
Show that for any probability measure. A part goes through two checks, which it passes with probabilities and . Nothing is known about how the checks are related. What can you say about the probability that it passes both?
Solution
From inclusion–exclusion, , since . For the checks, . The bound holds whatever the dependence between the checks, and it is attained when the two sets of failures are disjoint. If the checks were independent, the answer would be exactly .
More practice: Applebaum, Exercises 3.6, 3.10 and 3.16.
Conditional probability and Bayes' theorem
A test that is right 99% of the time can still be wrong most of the time it says "positive". The resolution is the difference between and , and Bayes' theorem is the rule for turning one into the other.
The idea
For a diagnostic test, (ill) and . The sensitivity is , the specificity is , and the prevalence is the prior. Bayes gives the posterior .
Explore
Worked example
30% of the email reaching an inbox is spam. A filter flags 95% of spam, and also flags 2% of genuine email.
What fraction of all email gets flagged?
By total probability, .
A message is flagged. What is the probability it is spam?
About 1 flagged message in 21 is genuine.
A message is not flagged. What is the probability it is spam?
Are "spam" and "flagged" independent? What would independence mean for the filter?
No: . Independence would mean that a flag carries no information about whether the message is spam, which happens exactly when the filter flags spam and genuine mail at the same rate. Try that in the explorer: set sensitivity specificity and the posterior equals the prior.
Check your understanding
A test has sensitivity and specificity both 0.99, and 1 person in 1000 has the disease. Roughly what is ?
- 0.99That is . The question asks for the reverse conditional probability.
- 0.5Count the positives in 1000 people: about 1 true positive and about 10 false ones.
- About 0.09
- 0.001That is the prior. A positive result should raise it.
and are disjoint events, each with positive probability. Can they be independent?
- Yes: they have nothing to do with each other.Disjoint does not mean unrelated: if happens, you know for certain that did not.
- No
- Only if .Check the definition: would have to equal .
A patient tests positive, then takes a second test of the same kind, whose result given the disease status is independent of the first, and is positive again. How should the probability be updated?
- Use the posterior after the first test as the prior and apply Bayes again.
- Multiply the first posterior by the sensitivity.That gives , not . You still have to divide by the probability of the second positive.
- The second test adds nothing new.It is independent given the disease status, so it is fresh evidence. Use the retest button in the explorer.
Practice
Three cardsConditioning on what you see
One card is red on both sides, one is white on both sides, and one is red on one side and white on the other. A card is drawn at random and placed on the table with a random side up. The visible side is red. What is the probability that the other side is red too?
Hint
Condition on the face you see, not on the card. There are six equally likely faces.
Solution
Of the six equally likely faces, three are red. Two of those belong to the red–red card. So , not . With Bayes: .
Pairwise is not enoughIndependence of three events
Toss two fair coins. Let = "first coin heads", = "second coin heads", = "the coins show the same face". Show that each pair of these events is independent, but the three are not.
Solution
Each event has probability . , , , each of probability . But has probability . Knowing and together determines , even though each alone tells you nothing about it.
More practice: Applebaum, Exercises 4.14, 4.20 and 4.29.
Discrete random variables
A random variable's law says how likely each value is; its mean and variance summarise where the values sit and how far they spread. Draw samples below and watch the histogram settle onto the law and the running average settle onto the mean.
The idea
Three laws that come up again and again:
- Binomial : the number of successes in independent trials, ; mean , variance .
- Poisson : for ; mean and variance both . It is the limit of as : many trials, each rarely a success.
- Geometric: the number of the trial on which the first success happens, for ; mean , variance .
Explore
Worked example
A batch contains 200 chips, each defective with probability 0.01 independently of the others. Let be the number of defective chips.
What is the law of ? Find .
, so .
Approximate the same probability with a Poisson law. Which ?
Match the means: . Then , within about 1% of the exact value.
Estimate both ways.
Use the complement. Exactly: . Poisson: . They agree to four decimal places.
Compare the variances. Why is the Poisson variance a little larger?
The binomial variance is ; the Poisson variance is . The factor is the only difference, and it tends to 1 as with fixed. That is the regime in which the Poisson approximation is good.
Check your understanding
and are independent. What is the law of ?
- Adding the two counts adds the numbers of trials, not the success probabilities. can be as large as 20.
- It is not binomial.Think of and as counting successes in two separate runs of independent trials.
In the simulator, the running mean wanders around . If you quadruple the number of draws, by what factor does its typical distance from shrink?
- 4That would be true of the variance of , not its standard deviation.
- 2
- It doesn't shrink; each draw is as random as the last.Each draw is, but the average of many draws is much less variable.
is uniform on and . Which is true?
- They are independent, because they are uncorrelated.Uncorrelated only says . Compare with .
- They are uncorrelated but not independent.
- They are correlated, since is a function of .Compute .
Practice
Mean of the geometric lawDifferentiating a series
Show that if for , then .
Hint
Differentiate for .
Solution
Differentiating gives . With , . On average a fair die takes 6 rolls to show its first six.
Thinning a Poisson countTotal probability with random variables
The number of emails arriving in an hour is . Each email, independently, is spam with probability . Show that the number of spam emails is Poisson with mean .
Hint
Given , . Sum over .
Solution
where . So .
More practice: Applebaum, Exercises 5.22, 5.23 and 5.36.
Information and entropy
A rare event is more informative than a common one. Entropy is the average information in the outcome of a random variable: how many yes/no questions, on average, it takes to pin down the outcome. Drag the bars below and find the shapes with the most and the least entropy.
The idea
It depends only on the probabilities, not on the values takes. For a Bernoulli variable, , which is 1 bit at .
with chosen to give the right mean. It is the "least committal" law consistent with what you know. In statistical mechanics the are energies and this is the Boltzmann distribution.
Explore
Worked example
Three fair coins are tossed. Let be the number of heads.
Write down the law of .
and .
How much information is there in learning ? In learning ?
bits, and bits.
Compute .
The full outcome (e.g. HTH) has 3 bits of entropy. Where did the other 1.19 bits go?
The full outcome is uniform on 8 sequences, so it has bits. is a function of it and forgets the order of the heads, which is why . In general : processing can only lose information. The missing bits is the average information in "which order", given the count.
Check your understanding
Which law on four outcomes has more entropy: or ?
- The first, because it is uniform.It is uniform only on two of the four outcomes, which gives bit.
- The second
- They are equal.Compute both: one is exactly 1 bit.
takes values . Let . How does compare with ?
- That is how the variance would scale (by , in fact). Entropy only sees the probabilities.
- , since is more spread out.Entropy does not measure spread of values; relabelling the outcomes changes nothing.
Among all laws on with mean 3.5, which has the largest entropy?
- The uniform law
- It has mean 3.5 but only 1 bit of entropy. Try it in the explorer.
- A Gibbs law with With the weights favour small values, so the mean is below 3.5.
Practice
The Bernoulli entropyA calculus check
Show that has its maximum at and is symmetric about it. Compute .
Solution
by its formula. In natural logs, , which is positive for , zero at and negative after. So the maximum is bit. bits.
Why uniform is the maximumThe Gibbs inequality
Using (equality only at ), show that , with equality only for the uniform law.
Hint
Look at , summing over the with .
Solution
In natural logs, . Equality needs for every with , and needs every to have ; that is the uniform law. Dividing by converts to bits.
More practice: Applebaum, Exercises 6.5, 6.6, 6.13 and 6.16.
Joint entropy and mutual information
How much does knowing tell you about ? Mutual information answers in bits: it is the drop in uncertainty about once is known. Reshape a joint law by dragging the dividers of the mosaic below and watch the entropies add up.
The idea
is the entropy of the conditional law of given , and is its average over . (The book writes .)
Explore
Worked example
and take values 0 and 1 with joint law , , , .
Find the marginal laws and their entropies.
, , so . , so .
Find .
bits.
Compute from its definition, and check the chain rule.
Given , is 0 or 1 with probabilities , so . Given , for certain, so . Then , and indeed .
Find two ways.
, and bits. Set the mosaic to these numbers (, , ) to check.
Check your understanding
. What can you conclude?
- and are independent.
- is a function of .Then and , the largest it can be.
- One of them is constant.That is enough for but not necessary. In the mosaic, line the two horizontal dividers up.
is a fair bit and . What is ?
- 0 tells you exactly. That is the opposite of independence.
- 1 bit
- 2 bitsThat is . But , not 0, so subtract it.
Which of these always holds?
- for every value Try "Y depends on X only sometimes": a rare value of after which is a fair coin.
- The inequality goes the other way: .
Practice
Two formulas for IExpanding the logarithm
Show that , where , are the marginals.
Solution
Split the logarithm: . The first sum is . In the second, summing over first gives ; similarly the third is . So the total is .
The last bitA function of a random variable
is uniform on and . Find , , , and .
Solution
, . is determined by , so . Given , is uniform on two values, so . Then bit, and the chain rule checks: .
More practice: Applebaum, Exercises 6.8 and 6.10.
Channels and capacity
A noisy channel garbles some of what is sent. The mutual information between input and output measures how much gets through, and the sender can tune it by choosing how often to send each symbol. The best achievable value is the channel's capacity, and Shannon's theorem says it is a hard speed limit for reliable communication.
The idea
In the binary symmetric channel each bit is flipped with probability , independently. If , then , and whatever was sent, so
with the maximum at , which makes uniform.
Explore
Worked example
In a "Z-channel", a 0 is always received correctly, but a 1 arrives as 0 with probability . Find its capacity and the input law that achieves it.
With , find the law of .
only if a 1 was sent and survived: .
Find .
Given , is certain: entropy 0. Given , is a fair coin: entropy 1. So .
Write as a function of and maximise it.
. Using ,
What is the capacity? What is surprising about the optimal input?
bits, which equals . The best input sends 1 only 40% of the time: since 1s are the unreliable symbol, it pays to use them less. For the symmetric channel the optimum is always , but in general the capacity-achieving input need not be uniform.
Check your understanding
A binary symmetric channel has . What is its capacity?
- 0
- bit, since half the bits arrive correctlyThey do, but the receiver can't tell which half. Set ε to 0.5 and look at the output law.
- 1 bitThat is the capacity of a perfect channel.
A binary symmetric channel flips each bit with probability 0.9. How does its capacity compare with a channel that flips with probability 0.1?
- It is the same.
- It is nearly zero.The receiver can flip every bit back. That turns it into a channel with ε = 0.1.
- It is lower than at ε = 0.5.The capacity is smallest at 0.5. Look at the capacity curve.
Why is the capacity defined as a maximum over input laws?
- The channel's noise is fixed, but the sender can choose how often to use each input symbol.
- Because is the same for every input law, so the maximum is just that value.Move the p slider: changes with the input law.
- To make the capacity independent of the noise.The capacity depends on the noise; for the symmetric channel it is .
Practice
A ternary channelCapacity by symmetry
Inputs and outputs are . Each input arrives as or as , with probability each. Find the capacity.
Hint
does not depend on the input law. Which input law makes as large as possible?
Solution
for each , so . , with equality when is uniform, which happens when is uniform. So bits.
The repetition codeReliable, but slow
Over a binary symmetric channel with , each message bit is sent three times and decoded by majority vote. Find the probability of a decoding error and the rate. How does this compare with what Shannon's theorem allows?
Solution
Decoding fails if at least two of the three copies are flipped: . The rate is bit per use. The capacity is , so Shannon's theorem promises codes with rate up to about 0.53 and error probability as small as we like. Repetition buys reliability by giving up rate, and longer repetition makes the rate tend to 0; good codes avoid this.
More practice: Applebaum, Exercises 7.1, 7.2 and 7.5.
Prefix codes and Huffman coding
To compress a source, give common symbols short codewords and rare ones long codewords. Entropy is the floor: no code can beat bits per symbol on average. Huffman's algorithm builds the best possible prefix code by repeatedly merging the two least likely symbols. Watch it work.
The idea
exactly when every is a power of . Otherwise the gap can be shrunk by coding blocks of symbols at a time, which gives bits per symbol.
Watch
- Six symbols, sorted by probability. Each one starts as a tree on its own.
- Merge the two least likely trees. The new node's probability is their sum.
- Repeat with the trees that remain: again take the two smallest.
- And again. A merged node is treated exactly like a symbol.
- After this merge only two trees are left.
- The last merge makes the root.
- Label left branches 0 and right branches 1. Each codeword is the path from the root to its symbol. Compare the average length with the entropy.
Worked example
A source emits five symbols with probabilities . Build a Huffman code and compare it with the entropy and with the Shannon–Fano lengths.
Carry out the merges.
. Now the smallest are and : . Then . Finally .
Read off the codeword lengths and the average length.
The symbol of probability 0.4 joins only at the last merge: length 1. The other four sit two merges below the 0.6 node: length 3 each. So bits. One valid code is . Kraft: .
Compute the entropy.
bits. So , with a gap of only about 0.05 bits.
What do the Shannon–Fano lengths give?
Lengths , so bits. It also lies within 1 bit of , as the theorem promises, but Huffman does half a bit better.
Check your understanding
Is there a binary prefix-free code for four symbols with codeword lengths 1, 2, 2, 3?
- Yes, for example 0, 10, 11, 110110 begins with 11, which is another codeword.
- No
- Yes, as long as the shortest word goes to the most likely symbolWhether the lengths are possible doesn't depend on the probabilities at all.
A source has two symbols with probabilities 0.9 and 0.1, so bits. What is the average length of its Huffman code?
- 0.469 bitsCodeword lengths are whole numbers, and each symbol needs at least one bit.
- 1 bit
- Somewhere between 0.469 and 1, depending on the codeWith two symbols the only sensible code is 0 and 1.
For which sources does the Huffman code achieve exactly?
- When every probability is a power of
- When the source is uniformTry three equally likely symbols: , but the best code has lengths 1, 2, 2 and .
- Always, since Huffman codes are optimalOptimal among codes, but codes have whole-number lengths, and usually isn't of that form.
Practice
Coding pairsThe extension of a source
For the source with probabilities 0.9 and 0.1, code pairs of independent symbols. Build the Huffman code for the four pairs and find the average length per original symbol.
Solution
The pairs have probabilities 0.81, 0.09, 0.09, 0.01. Merge , then , then . Lengths: 1, 2, 3, 3, so bits per pair, or 0.645 bits per symbol, against . The bound says blocks of length are within of per symbol.
Likely symbols get short wordsAn exchange argument
Show that in a code of minimal average length, if then .
Solution
Suppose but . Swap the two codewords. The code is still prefix-free, and the average length changes by . So the original code was not minimal.
More practice: Applebaum, Exercises 7.9, 7.12 and 7.15.
Densities and the central limit theorem
Add up many independent random quantities and, whatever their own shape, the sum looks normal. That is the central limit theorem, and it is why the bell curve is everywhere. Pick a lopsided distribution below, add copies, and watch the histogram of the standardised sum turn into the normal curve.
The idea
Explore
Worked example
A fair die is rolled 100 times. Estimate the probability that the total is at least 380.
Find the mean and variance of a single roll.
, and , so .
Find the mean and standard deviation of the total .
and , so the standard deviation is about .
Standardise and use the normal approximation.
takes whole-number values, so "" is the same as "" (a continuity correction). Then
The exact value, from convolving the die's law 100 times, is 0.0420.
What does Chebyshev's inequality give? Why is it so much weaker?
, and that bounds both tails together. Chebyshev uses only the variance, so it must hold for every distribution with that variance, including very spread-out ones. The CLT uses the fact that is a sum of many independent pieces.
Check your understanding
are i.i.d. Uniform(0, 1). For large , what does the CLT say about ?
- It is approximately .
- It is approximately .Those are the mean and variance of one term. For a sum of independent terms, means add and variances add.
- It is approximately uniform on .Run the simulator with the uniform law and : the sum is already a triangle, not flat.
Can a probability density function take values bigger than 1?
- Yes
- No, because is a probability. is a probability per unit length. Only its integrals are probabilities.
- Only at finitely many points.The uniform density on is 2 on the whole interval.
What is the entropy of the uniform density on ?
- bit
- It can't be negative, so 0.That is true for discrete entropy, where each . A density can exceed 1, which makes negative.
- 1 bitCheck the sign: and .
Practice
Four hundred tossesNormal approximation to the binomial
A fair coin is tossed 400 times. Estimate the probability that the number of heads is between 190 and 210 inclusive.
Solution
The count is , with mean 200 and standard deviation . With a continuity correction, . (The exact binomial value is also 0.706 to three places.)
From uniform to exponentialThe distribution-function method
Let be uniform on and . Find the density of .
Hint
Compute for first.
Solution
For , . So and : is exponential with . This is how the simulator above generates exponential samples.
More practice: Applebaum, Exercises 8.19, 8.34 and 8.37.
Random vectors and conditional densities
Two random quantities measured together have a joint density. Slicing it at gives the conditional density of , and how much narrower that slice is than 's own density measures how much tells you about . For the bivariate normal everything is explicit.
The idea
Explore
Worked example
A point is chosen uniformly in the unit disc . Find the marginal and conditional densities, and decide whether and are correlated, and whether they are independent.
What is the joint density? Find .
The disc has area , so inside it. For , the vertical line at meets the disc in an interval of length , so .
Find the conditional density of given .
for : uniform on the chord. Its spread depends on .
Compute .
The disc is symmetric under , so and . Hence : uncorrelated.
Are and independent?
No. At , outside the disc, , but . Equivalently, the conditional law of changes with . (For the bivariate normal, by contrast, does give independence: set above and the slice matches for every .)
Check your understanding
is standard bivariate normal with . Given , what is the law of ?
- The conditional mean is , not . Move the slice to and read off the peak.
- Knowing also narrows the spread of : the conditional variance is .
on the unit square . Are and independent?
- Yes, because the density lives on a rectangle.A rectangular range is needed for independence, but not enough. The density itself must factor.
- No
- Yes, by symmetry in and .Symmetry says and have the same law, not that they are independent.
What happens to for the bivariate normal as ?
- It tends to infinity.
- It tends to 1 bit.1 bit is the most two binary variables can share. Continuous variables can share far more.
- It tends to 0.The variables become more strongly dependent, not less. Slide ρ toward 0.95.
Practice
A waiting-time pairMarginals and conditionals
has joint density for . Find , and both conditional densities.
Solution
for , and for . Then for , so given , is exponential with . And for : given , is uniform on .
Is more power worth it?The Gaussian channel
Using , find how much the capacity increases when the signal power is doubled, first at , then at .
Solution
At : , so about half a bit more, on top of . At : goes from to , almost exactly double. At low signal-to-noise ratio capacity is roughly proportional to power; at high ratio, each doubling adds only half a bit.
More practice: Applebaum, Exercises 9.17, 9.22 and 9.27.
Markov chains and entropy rate
A Markov chain forgets everything except where it is now. That one rule makes it settle into an equilibrium from any start, and it makes the information it produces per step easy to compute. Set the two switching probabilities and watch the chain converge.
The idea
the average, under , of the entropies of the rows of . It satisfies , with equality exactly when all the rows are equal, that is, when the are i.i.d.
Explore
Worked example
A particle moves on the states with transition matrix
Starting from 0, what is the law of ?
It is the first row of : .
Find the invariant distribution.
Solve . The first column gives , so ; by symmetry . With : . has all entries positive, so this is the limit from any start.
Compute the entropy rate.
The rows have entropies 1, 1.5 and 1 bits. So bits per step.
Compare with and interpret.
bits. An i.i.d. sequence with the same one-step law would produce 1.5 bits per step; the chain produces only 1.25, because each step is partly predictable from the last. A source like this can be compressed to about 1.25 bits per symbol, but only by a code that uses the previous symbol.
Check your understanding
The two-state chain above has and , with . What is , the long-run fraction of time in state 0?
- A large means the chain leaves 0 quickly, so it should spend less time there, not more.
- , by symmetryThe two states are only symmetric when .
Take : the chain switches state at every step. Starting from 0, does converge?
- Yes, to Starting from 0, the chain is at 0 at every even time and at 1 at every odd time. Set both sliders to 1.
- No, it alternates between 1 and 0, although is invariant.
- No, and there is no invariant distribution.Check .
For a stationary Markov chain with invariant law , which is always true?
- , and conditioning cannot increase entropy on average.
- Only when is independent of . Try .
Practice
A walk around a cycleDoubly stochastic matrices
A particle on the cycle () steps one place clockwise or anticlockwise with probability each. Show that the uniform law is invariant and find the entropy rate. For which does converge?
Solution
Every column of also sums to 1, so . Each row has two entries , so bit per step, while . For even the chain alternates between even and odd states, so for odd and there is no convergence. For odd some power of is positive and the probability tends to .
A sticky chainEntropy rate of two states
Compute , and for the two-state chain with , . Check your answers in the explorer.
Solution
. bits, while bits. The chain stays put most of the time, which makes it more predictable than an i.i.d. sequence spending the same fraction of time in each state.
More practice: Applebaum, Exercises 10.14, 10.23 and 10.24.