IB Diploma Mathematics AI · Statistics and probability
Markov chains (HL)
1States and transition matrices
A Markov chain models a system that moves between states in steps, where the next state depends only on the current state, not on the earlier history.
- The transition matrix $T$ holds the probabilities of moving from each state to each state.
- In IB notation each column is a "from" state and each row is a "to" state, so each column adds up to 1.
- A transition diagram shows the states as circles and the probabilities on arrows.
Transition diagram for the weather: each state's outgoing probabilities add to 1
weather is Sunny (S) or Rainy (R). After a sunny day, the next day is sunny with probability 0.8. After a rainy day, it is sunny with probability 0.4.
$T = \begin{pmatrix}0.8 & 0.4\\0.2 & 0.6\end{pmatrix}$, with columns "from S" and "from R".
Check yourself
In an IB transition matrix, what must each column add up to?
Show the answer
1
From any state, the system must go somewhere.
2Predicting future states
A state vector $\mathbf{s}_0$ gives the probabilities (or proportions) of being in each state now.
- After one step: $\mathbf{s}_1 = T\mathbf{s}_0$.
- After $n$ steps: $\mathbf{s}_n = T^n\mathbf{s}_0$. Use the GDC for powers of $T$.
- The state vector can also hold actual numbers, such as how many customers use each shop.
Weather in two days
- Today is sunny: $\mathbf{s}_0 = \begin{pmatrix}1\\0\end{pmatrix}$.
- $\mathbf{s}_1 = T\mathbf{s}_0 = \begin{pmatrix}0.8\\0.2\end{pmatrix}$.
- $\mathbf{s}_2 = T\mathbf{s}_1 = \begin{pmatrix}0.8 \times 0.8 + 0.4 \times 0.2\\0.2 \times 0.8 + 0.6 \times 0.2\end{pmatrix} = \begin{pmatrix}0.72\\0.28\end{pmatrix}$.
- $P(\text{sunny in two days}) = 0.72$. After three days it is 0.688.
Check yourself
Which product gives the state vector after 5 steps?
Show the answer
T⁵s₀
Apply T five times; T sits on the left.
3The steady state
Over many steps the state vector usually settles to a steady state $\mathbf{s}$ that no longer changes:
$T\mathbf{s} = \mathbf{s}$
- So $\mathbf{s}$ is an eigenvector of $T$ with eigenvalue 1, scaled so its entries add to 1.
- To find it, solve $T\mathbf{s} = \mathbf{s}$ together with "entries add to 1", or work out $T^n$ for a large $n$ on a GDC: every column approaches $\mathbf{s}$.
- The steady state does not depend on the starting state (for the regular chains in this course).
Long-run weather
- Let $\mathbf{s} = \begin{pmatrix}p\\q\end{pmatrix}$ with $p + q = 1$.
- Top row of $T\mathbf{s} = \mathbf{s}$: $0.8p + 0.4q = p$, so $0.4q = 0.2p$ and $p = 2q$.
- With $p + q = 1$: $q = \frac{1}{3}$, $p = \frac{2}{3}$.
- In the long run, $\frac{2}{3}$ of days are sunny, whatever today is like.
Check yourself
A steady state s satisfies Ts = s. What is s in the language of eigenvectors?
Show the answer
An eigenvector of T with eigenvalue 1
Ts = 1 × s.
4Markov chains in context
- Market share: proportions of customers using brands A and B each month.
- Population movement: people moving between city and countryside each year.
- Read the question carefully to set up the columns as "from" states.
- To find when a share first passes a value, compute $T^n\mathbf{s}_0$ for $n = 1, 2, 3, \ldots$ on a GDC.
- With diagonalisation, $T^n = PD^nP^{-1}$, where $D$ holds the eigenvalues. Because the other eigenvalue is smaller than 1 in size, its power shrinks to 0, which is why the chain settles.
Two gyms
- Each month 90% of gym A's members stay and 10% move to B. Gym B keeps 70% and loses 30% to A.
- $T = \begin{pmatrix}0.9 & 0.3\\0.1 & 0.7\end{pmatrix}$.
- Steady state: $0.1p = 0.3q$, so $p = 3q$, giving $p = 0.75$, $q = 0.25$.
- In the long run gym A has 75% of the members.
Check yourself
For the weather matrix, the eigenvalues are 1 and 0.4. What happens to 0.4ⁿ as n grows?
Show the answer
It tends to 0, so the chain settles to its steady state
Powers of a number between −1 and 1 shrink to 0.
5Building a transition matrix
Weather
- If today is sunny, tomorrow is sunny with probability 0.8 and rainy with 0.2.
- If today is rainy, tomorrow is sunny with probability 0.4 and rainy with 0.6.
- Transition matrix (columns are "from"): $T = \begin{pmatrix} 0.8 & 0.4 \\ 0.2 & 0.6 \end{pmatrix}$.
- Each column sums to 1.
- Starting sunny, $\mathbf{s}_0 = \begin{pmatrix} 1 \\ 0 \end{pmatrix}$. After two days: $T^2\mathbf{s}_0 = \begin{pmatrix} 0.72 \\ 0.28 \end{pmatrix}$.
Check yourself
In a column-based transition matrix, what must each column sum to?
Show the answer
1
Probabilities from one state.
6Finding the steady state
The steady state $\mathbf{s}$ satisfies $T\mathbf{s} = \mathbf{s}$, with entries adding to 1.
Using the weather matrix
- Let $\mathbf{s} = \begin{pmatrix} p \\ 1 - p \end{pmatrix}$.
- First row: $0.8p + 0.4(1 - p) = p$.
- $0.4 + 0.4p = p$, so $0.6p = 0.4$ and $p = \frac{2}{3}$.
- Steady state: sunny $\frac{2}{3}$, rainy $\frac{1}{3}$.
- In the long run, about two-thirds of days are sunny, whatever the starting weather.
The steady state is the eigenvector of $T$ for eigenvalue 1.
Check yourself
What eigenvalue corresponds to the steady state of a Markov chain?
Show the answer
1
$T\mathbf{s} = \mathbf{s}$.
Now test yourself
This lesson has a 8-question quiz and 5 exam-style questions with mark schemes in Impera. Free, with your progress saved.
Practise in Impera