Matrices, Markov chains and systems of equations
IB Math AI · Number and Algebra
Matrix algebra you actually use
Matrix multiplication is defined when the inner dimensions agree: an $m\times n$ times an $n\times p$ gives $m\times p$. It is not commutative: in general $AB\neq BA$, and one of the two may not even exist.
For a $2\times2$ matrix, $\det A=ad-bc$ and
$$A^{-1}=\frac{1}{ad-bc}\begin{pmatrix}d&-b\\-c&a\end{pmatrix}$$A system of linear equations becomes $AX=B$, solved as $X=A^{-1}B$. If $\det A=0$ there is no unique solution — the GDC reports an error rather than a number.
Transition matrices and Markov chains
With state vectors written as columns, $s_{n+1}=Ts_{n}$ and $s_{n}=T^{n}s_{0}$. Every column of $T$ sums to $1$, because everything leaving a state must go somewhere.
The steady state $s$ satisfies $Ts=s$, i.e. it is the eigenvector of $T$ for the eigenvalue $\lambda=1$, scaled so its entries add to $1$.
Eigenvalues
$$\det(A-\lambda I)=0$$For a $2\times2$ matrix this is $\lambda^{2}-(\operatorname{tr}A)\lambda+\det A=0$. Every transition matrix has $\lambda_{1}=1$; the second eigenvalue controls how fast the chain settles, because the distance from the steady state is multiplied by $\lambda_{2}$ each step.
Worked example: three steps of a Markov chain and the steady state
Use the transition matrix in the figure. This week $40\%$ of the people in the surveyed group take the bus.
(a) Calculate the proportion taking the bus after $1$, $2$ and $3$ weeks. (b) Find the long-term proportion.
Solution
(a) With $s_{0}=\begin{pmatrix}0.40\\0.60\end{pmatrix}$, the first component of $s_{n+1}$ is $0.85b_{n}+0.30m_{n}$:
| Week | $0$ | $1$ | $2$ | $3$ |
|---|---|---|---|---|
| Bus | $0.400$ | $0.520$ | $0.586$ | $0.622$ |
| Motorbike | $0.600$ | $0.480$ | $0.414$ | $0.378$ |
Detail of the first step: $0.85(0.40)+0.30(0.60)=0.34+0.18=0.52$.
(b) The steady state satisfies $b=0.85b+0.30m$ with $b+m=1$:
$$b=0.85b+0.30(1-b)\;\Rightarrow\;0.45b=0.30\;\Rightarrow\;b=\tfrac{2}{3}=0.667$$So in the long run about $66.7\%$ take the bus and $33.3\%$ take the motorbike. The sequence $0.400$, $0.520$, $0.586$, $0.622$ is creeping up to exactly that figure, and creeping more and more slowly: each week it closes exactly $55\%$ of the remaining gap. The next example shows where that $55\%$ comes from.
Worked example: eigenvalues show how fast the system settles
With $T=\begin{pmatrix}0.85&0.30\\0.15&0.70\end{pmatrix}$: (a) find the two eigenvalues; (b) use them to explain why the gap between the proportion taking the bus and the value $\tfrac{2}{3}$ decreases geometrically, and estimate after how many weeks that gap is below $1$ percentage point.
Solution
(a) $\operatorname{tr}T=0.85+0.70=1.55$ and $\det T=0.85(0.70)-0.30(0.15)=0.595-0.045=0.55$, so
$$\lambda^{2}-1.55\lambda+0.55=0\;\Rightarrow\;(\lambda-1)(\lambda-0.55)=0$$$$\lambda_{1}=1,\qquad \lambda_{2}=0.55$$(b) Write $s_{0}$ as the sum of the eigenvector for $\lambda_{1}=1$ (which is the steady state $s^{*}$) and a part along the eigenvector for $\lambda_{2}$. Multiplying by $T$ keeps the first part unchanged and multiplies the second part by $0.55$, so
$$s_{n}-s^{*}=(0.55)^{n}\,(s_{0}-s^{*})$$Check with the data of the previous example: $0.400-0.667=-0.267$; multiplying by $0.55$ gives $-0.147$, and $0.667-0.147=0.520$, exactly the week-one figure. Multiplying again gives $-0.081$ and $0.586$, then $-0.044$ and $0.622$.
For the gap to be below $0.01$:
$$0.267(0.55)^{n}<0.01\;\Rightarrow\;(0.55)^{n}<0.0375\;\Rightarrow\;n>\frac{\ln 0.0375}{\ln 0.55}=5.50$$So from week $6$ onward. Practical meaning: it takes only about a month and a half for the travel pattern to be considered settled, wherever it started, and that is the kind of conclusion the IB's “comment on your answer” is waiting for.
Common mistake
First trap: mixing the row convention and the column convention. Textbooks and software differ on this. If the state vector is a column, then the columns of $T$ add to $1$ and we multiply $Ts$; if the state vector is a row, then the rows add to $1$ and we multiply $sT$. Mixing the two conventions gives a vector that still adds to $1$, still looks like a probability distribution, so nothing sounds an alarm.Second trap: thinking the steady state depends on the starting point. For a transition matrix with all positive entries, the steady state is unique and every $s_{0}$ leads to it. What depends on $s_{0}$ is only the time to get there, not the destination.
Third trap: forgetting to normalize the eigenvector. The calculator returns an arbitrary eigenvector, for example $\begin{pmatrix}0.894\\0.447\end{pmatrix}$. That is not yet the steady state: you must divide by the sum $1.341$ to get $\begin{pmatrix}0.667\\0.333\end{pmatrix}$. Skip the division and the two numbers are still in the right ratio but are no longer proportions.