Markov chains: watching probability flow
The question
A walker hops between three states by fixed odds. After 20 steps, which state is it most likely to be in?
Stage 1 asks for your pick before any step is taken.
- 1 SeePick the likeliest state at step 20.
- 2 TryTwo steps, the long run, then steer a chain.
- 3 ProveBuild the proof, line by line.
- 4 ApplyCommutes, credit ratings and a machine.
Before you start · 3 quick checks on a matrix product, the multiplication rule and a PMF, about 3 min
Two ideas before you start
2 ideasThe arrows out of a state carry its odds
Figure: a chain with the states A, B and C in a row; the arrows out of the chosen state are drawn bold, with their probabilities. It needs JavaScript.
Row A of P: 0.6 + 0.4 + 0 = 1
At each step the walker leaves its state along one arrow, with the probability on that arrow. The arrows out of a state add up to 1, and they form that state's row of the transition matrix P.
Exact definition
Markov chain. A Markov chain on the states \(1, \dots, N\) (on this page often A, B and C) is a sequence of random variables \(X_{0}, X_{1}, X_{2}, \dots\), where \(X_{n}\) is the state at step \(n\). Its transition matrix \(P\) has the entries \(p_{ij}\), the probability of a move from \(i\) to \(j\) in one step. Every \(p_{ij} \ge 0\), and every row adds up to 1: \(\sum_{j} p_{ij} = 1\) for each state \(i\). The same \(P\) is used at every step.
The distribution at step \(n\) is the row vector \(\pi_{n} = (P(X_{n} = 1), \dots, P(X_{n} = N))\); its entries add up to 1. We also write \(\pi_{n}(j) = P(X_{n} = j)\). The row \(\pi_{0}\) is the initial distribution.
Only the current state matters
Figure: the same chain; the arrow from the chosen state into B is dashed, and the arrows out of B are drawn bold. It needs JavaScript.
X₀ = A, X₁ = B. Next step: A 0.2 B 0.5 C 0.3
The walker is at B at step 1. Wherever it was at step 0, its next step uses the arrows out of B. This is the Markov property.
Exact definition
Markov property. For every \(n \ge 0\) and all states \(i_{0}, \dots, i_{n-1}, i, j\) with \(P(X_{0} = i_{0}, \dots, X_{n-1} = i_{n-1}, X_{n} = i) \gt 0\),
\[\begin{aligned} &P(X_{n+1} = j \mid X_{n} = i, \\ &\qquad X_{n-1} = i_{n-1}, \dots, X_{0} = i_{0}) \\ &= p_{ij}. \end{aligned}\]Once \(X_{n}\) is known, the earlier states change nothing about the next one. In particular, \(P(X_{n+1} = j \mid X_{n} = i) = p_{ij}\) whenever \(P(X_{n} = i) \gt 0\). The lesson on conditional probability defines \(P(A \mid B)\).
Fine print: rows, columns and time
This page writes a distribution as a row and multiplies it on the left of \(P\), the usual convention for Markov chains. Some books write the distribution as a column and use the transpose of \(P\); the numbers are the same. Every chain here has finitely many states, and its \(P\) does not change from step to step.
Where will the walker most likely be at step 20?
- Pick A, B or C: the state you expect to be the most likely at step 20. The pick is locked.
- Then press One step, Play or Jump to step 20. Each box fills with the probability that the walker is there.
- At step 20 the page marks your pick and explains the result. There are three chains.
Your pick for step 20:
Two steps, and many steps
Two questions first: one applies the rule from stage 1, one asks for a prediction. The explorer below them opens once both are answered.
The explorer opens when you have answered the two questions above.
Explorer: a chain with two states
From A the walker moves to B with probability \(a\) and stays with probability \(1 - a\); from B it moves to A with probability \(b\) and stays with probability \(1 - b\). Choose \(a\), \(b\) and a step \(n\). The figure draws \(P(X_{k} = A)\) at every step \(k\) up to 30, for a start at A and for a start at B. The tiles give \(P\) and the two rows of \(P^{n}\), computed exactly and rounded to 4 decimal places where needed. In a two-state chain, \[\begin{aligned} &P(X_{n} = A \mid X_{0} = A) \\ &\quad - P(X_{n} = A \mid X_{0} = B) \\ &= (1 - a - b)^{n}, \end{aligned}\] with \(0^{0} = 1\).
Goals
Why n steps multiply by P to the n
Assumptions. Let \(X_{0}, X_{1}, X_{2}, \dots\) be a Markov chain on \(N \ge 2\) states with transition matrix \(P\): every \(p_{ij} \ge 0\), every row adds up to 1, and the Markov property of the setup holds with the same \(P\) at every step. For every \(n \ge 0\), \(\pi_{n}\) is the row \((P(X_{n} = 1), \dots, P(X_{n} = N))\). As usual, \(P^{0} = I\) and \(P^{n+1} = P^{n}P\).
Conclusion. For every \(n \ge 0\),
\[\pi_{n} = \pi_{0}P^{n},\]and for all states \(i\) and \(j\) with \(P(X_{0} = i) \gt 0\),
\[P(X_{n} = j \mid X_{0} = i) = (P^{n})_{ij}.\]Facts the proof uses.
- the law of total probability, from the lesson on conditional probability;
- matrix products may be regrouped, \((AB)C = A(BC)\), from the lesson on matrix multiplication;
- given \(X_{0} = i\), with \(P(X_{0} = i) \gt 0\), the sequence \(X_{0}, X_{1}, \dots\) is again a Markov chain with the same \(P\), started at \(i\).
Each option is one sentence about the chain of the theorem. Pick the one that is true for every chain the theorem covers: any \(N \ge 2\), any \(P\) and any initial distribution \(\pi_{0}\).
- Paths. For \(n \ge 1\), writing out the product \(P^{n}\) entry by entry, \((P^{n})_{ij}\) is the sum of \(p_{ik_{1}}\,p_{k_{1}k_{2}} \cdots p_{k_{n-1}j}\) over all paths \(i \to k_{1} \to \dots \to k_{n-1} \to j\) of \(n\) steps. For \(n = 0\), \((P^{0})_{ij}\) is 1 when \(j = i\) and 0 otherwise.
- Split a trip. For all \(m, n \ge 0\), \(P^{m+n} = P^{m}P^{n}\), so whenever \(P(X_{0} = i) \gt 0\), \[\begin{aligned} &P(X_{m+n} = j \mid X_{0} = i) \\ &= \sum_{k} (P^{m})_{ik}\,(P^{n})_{kj}: \end{aligned}\] add over the state \(k\) at step \(m\). These are the Chapman–Kolmogorov equations.
- Rows of \(P^{n}\). Each row of \(P^{n}\) is a distribution: its entries are at least 0 and add up to 1.
- Distributions that stay put. If \(\pi_{0}P = \pi_{0}\), then \(\pi_{n} = \pi_{0}\) for every \(n\). Such a distribution is called stationary. Which chains have one, and when \(\pi_{n}\) approaches it, is the subject of a later lesson.
Problems
Each problem states its model and has hints and a full solution. Exact answers can be typed as decimals or as fractions.
Further reading
- J. R. Norris, Markov Chains (Cambridge University Press, 1997), ch. 1, "Discrete-time Markov chains," section 1.1, on the definition and n-step transition probabilities.
- J. K. Blitzstein and J. Hwang, Introduction to Probability, 2nd ed. (CRC Press, 2019), ch. 11, "Markov Chains," section 11.1.
- S. Ross, Introduction to Probability Models, 12th ed. (Academic Press, 2019), ch. 4, "Markov Chains," sections 4.1–4.2 on the Chapman–Kolmogorov equations.