Back to the on-screen lesson ·
H(X) = lim H(Xⁿ)/n = lim H(Xₙ | past) for stationary sources; Markov chains.
Paper packet. Every task here also exists on screen, where it is checked automatically; answers written on paper are not assessed by Nydus. When you are back at a device, enter your answers there.
By the end of this lesson you will be able to define the entropy rate of a stationary source, prove that its two natural definitions agree, explain why memory can only lower it, and compute it for i.i.d. sources and for stationary Markov chains as the stationary average of the row entropies. You will run arithmetic coding by hand on a short message, find the interval it produces and the number of bits it needs, and explain why its overhead is two bits per message rather than up to one bit per symbol, which is how practical compressors reach the entropy rate without grouping symbols into blocks.
For a source with memory the per-symbol information is the entropy rate $$H(\mathcal{X}) = \lim_{n \to \infty} \frac{H(X_1, \ldots, X_n)}{n},$$ and for a stationary source this equals $\lim_n H(X_n \mid X_1, \ldots, X_{n-1})$: the conditional entropies decrease (conditioning on a longer past reduces entropy, and stationarity keeps the comparison fair), so they converge, and $H(X^n)/n$ is their running average by the chain rule. Memory can only lower the rate: $H(\mathcal{X}) \le H(X_1)$, with equality for i.i.d. sources. For a stationary Markov chain with transition matrix $P$ and stationary distribution $\pi$, the rate is $H(X_2 \mid X_1) = \sum_i \pi_i H(P_{i\cdot})$, the average row entropy; a symmetric binary chain that switches with probability $p$ has rate $h(p)$. The AEP and the source coding theorem hold with $H(\mathcal{X})$ in place of $H$ for stationary ergodic sources, so English text compresses to its entropy rate, about one bit per letter, not to the $4.1$ bits of its letter frequencies.
Another way: story
Predicting the next letter of a sentence: with no context you face $4.1$ bits of uncertainty per letter; knowing the previous letters, a fluent reader is rarely surprised. The entropy rate measures the surprise of the fluent reader, and that is what a good compressor achieves.
Another way: steps
For a source with memory, 'bits per symbol' needs care: the first symbol may be more surprising than the thousandth. Two limits offer themselves, $$H(\mathcal{X}) = \lim_n \frac{H(X_1, \ldots, X_n)}{n} \quad \text{and} \quad H'(\mathcal{X}) = \lim_n H(X_n \mid X_1, \ldots, X_{n-1}),$$ and for a stationary source they agree. Why: the conditional entropies decrease, because conditioning on more reduces entropy and stationarity lets us shift the window, $H(X_n \mid X^{n-1}) \le H(X_n \mid X_2^{n-1}) = H(X_{n-1} \mid X^{n-2})$. A decreasing sequence bounded below converges. By the chain rule $H(X^n)/n$ is the running average of exactly that sequence, and the average of a convergent sequence converges to the same limit (Cesàro).
The consequence to remember: memory can only lower the rate, $H(\mathcal{X}) \le H(X_1)$, with equality exactly for i.i.d. sources. English has about $4.1$ bits per letter if you ignore context and roughly $1$ bit per letter if you use it — the difference is what a compressor lives on.
For a stationary Markov chain the past matters only through the current state, so $H(X_n \mid X^{n-1}) = H(X_2 \mid X_1)$ for every $n$ and the limit is reached immediately: $$H(\mathcal{X}) = H(X_2 \mid X_1) = \sum_i \pi_i H(P_{i\cdot}),$$ the entropy of each row of the transition matrix, averaged with the stationary distribution $\pi$.
| source | stationary distribution $\pi$ | row entropies | entropy rate | $H(X_1)$ |
|---|---|---|---|---|
| i.i.d. fair bits | $(0.5, 0.5)$ | $1, 1$ | $1$ | $1$ |
| sticky chain, stay w.p. $0.9$ | $(0.5, 0.5)$ | $h(0.1), h(0.1)$ | $0.469$ | $1$ |
| sticky chain, stay w.p. $0.75$ | $(0.5, 0.5)$ | $h(0.25), h(0.25)$ | $0.811$ | $1$ |
| asymmetric chain | $(\tfrac{1}{2}, \tfrac{1}{2})$ | $0.5, 1$ | $0.75$ | $1$ |
Row two is the one the practice uses: a binary chain that stays with probability $q$ and switches with probability $p = 1 - q$ is symmetric, so $\pi = (\tfrac{1}{2}, \tfrac{1}{2})$, both rows have entropy $h(p)$, and the rate is simply $h(p)$ — even though each symbol on its own is a fair bit with entropy $1$. Memory has cut the rate by more than half.
Common mistakes
The chain repeats its symbol with probability $0.9$ and switches with probability $0.1$; by symmetry $\pi = (\tfrac{1}{2}, \tfrac{1}{2})$.
Stationary distribution first.
Each row has entropy $h(0.1) = 0.469$, so the rate is $0.469$ bits per symbol, though each symbol alone is a fair bit with $H(X_1) = 1$.
Memory halves the information.
$H(X_n \mid X^{n-1}) \le H(X_n \mid X_2^{n-1}) = H(X_{n-1} \mid X^{n-2})$: conditioning on less, then shifting by stationarity.
A nonincreasing sequence bounded below converges.
$H(X^n)/n = \tfrac{1}{n} \sum_{i=1}^n H(X_i \mid X^{i-1})$, the average of a convergent sequence, converges to the same limit.
Chain rule plus Cesàro.
Switching probability $p = 0.2$; by symmetry $\pi = (\tfrac{1}{2}, \tfrac{1}{2})$.
Each row of the transition matrix is $(0.8, 0.2)$, with entropy $h(0.2) = 0.722$.
Rate $= 0.5 \cdot 0.722 + 0.5 \cdot 0.722 = 0.722$ bits per symbol, against $H(X_1) = 1$.
Predicting from the previous symbol saves $0.278$ bits each time.
$\pi = (\tfrac{1}{2}, \tfrac{1}{2})$; from state $0$ the next symbol has entropy $0.5$ bits, from state $1$ it has $1$ bit.
Rate $= \tfrac{1}{2} \cdot 0.5 + \tfrac{1}{2} \cdot 1 = 0.75$ bits per symbol.
Weight by how often the chain visits each state, not by the number of states.
Sanity check: the rate lies between the smallest row entropy $0.5$ and the largest $1$.
Rate $= \tfrac{1}{2} \cdot 0.5 + \tfrac{1}{2} \cdot 1$.
$0.75$ bits per symbol.
A binary Markov chain stays in its current state with probability $0.6$ and switches with probability $0.4$. What is its entropy rate in bits per symbol, to three decimal places?
Computed value: answer
A stationary two-state Markov chain has stationary distribution $(\tfrac{1}{2}, \tfrac{1}{2})$; from state $0$ the next symbol has entropy $2/4$ bits and from state $1$ it has entropy $4/4$ bits. What is the entropy rate?
Computed value: answer
An i.i.d. source has $H(X_1) = 5/2$ bits. What is $H(X_1, \ldots, X_{40})$, and hence the entropy rate? Enter the entropy rate.
Computed value: answer
A binary Markov chain stays in its current state with probability $0.95$ and switches with probability $0.05$. What is its entropy rate in bits per symbol, to three decimal places?
Computed value: answer
For a stationary source, which statement about the entropy rate is correct?
Lesson test: one question per skill, one attempt each, no hints. Your answers are checked when you submit.
A stationary two-state Markov chain has stationary distribution $(\tfrac{1}{2}, \tfrac{1}{2})$; from state $0$ the next symbol has entropy $4/4$ bits and from state $1$ it has entropy $2/4$ bits. What is the entropy rate?
Computed value: answer
You can find the entropy rate of a source with memory and code a message to within two bits of its information. This closes source coding; the next unit turns to noisy channels.
10. Your turn: a chain with $\pi = (\tfrac{1}{2}, \tfrac{1}{2})$, row entropies $0.5$ and $1$, step 2