Markov Chains & Long-Run Behavior

Study Sheet

Markov Chains & Long-Run Behavior

Steady states, mixing, and absorbing states

Probability Meets Eigenvectors

Tip
Transition matrices and the eigenvalue 1
AB0.30.40.70.6
From A: stay with probability 0.7, move to B with 0.3. From B: stay 0.6, move to A 0.4.

A Markov chain hops among states with fixed probabilities. Its transition matrix MM has Mij=M_{ij} = the probability of moving to state ii from state jj, so its entries are nonnegative and each column sums to 11. A distribution x\mathbf x (nonnegative, entries summing to 11) evolves by xn+1=Mxn\mathbf x_{n+1} = M\mathbf x_n.

That column condition forces λ=1\lambda = 1 to be an eigenvalue (the all-ones vector is a left eigenvector), and its right eigenvector — normalized to sum to 11 — is the steady state: the distribution the chain settles into regardless of where it started. Finding it is one homogeneous solve: (M−I)v=0(M - I)\mathbf v = \mathbf 0. All other eigenvalues have ∣λ∣≤1|\lambda| \le 1, and the second-largest, ∣λ2∣|\lambda_2|, sets the mixing rate: the memory of the starting state decays like ∣λ2∣n|\lambda_2|^n. For the two-state chain in the figure, M=(0.70.40.30.6)M = \begin{pmatrix}0.7&0.4\\0.3&0.6\end{pmatrix} and (M−I)v=0(M - I)\mathbf v = \mathbf 0 reads −0.3v1+0.4v2=0-0.3v_1 + 0.4v_2 = 0, so v1:v2=4:3v_1 : v_2 = 4 : 3 and the steady state is (47,37)\left(\tfrac47, \tfrac37\right). The other eigenvalue is tr⁡M−1=0.3\operatorname{tr}M - 1 = 0.3, so the memory of the start shrinks by a factor 0.30.3 each step.

Side note
PageRank is a steady state

Google's original algorithm models a random web surfer: from each page, follow a random link (with occasional random jumps). The importance of a page is its share of the steady-state distribution of that Markov chain — the λ=1\lambda = 1 eigenvector of a matrix with billions of rows, computed by simply iterating v↦Mv\mathbf v \mapsto M\mathbf v (the power method) until it stops changing. A trillion-dollar company, built on this chapter.

Tip
Absorbing chains and expected times

Some states trap you (absorbing); the natural question becomes "how long until absorption?" First-step analysis: from state ii, one step happens, then you are somewhere new — so Ei=1+∑jpijEjE_i = 1 + \sum_j p_{ij}E_j, a small linear system in the expected times.

A state that advances with probability pp and stalls otherwise contributes 1p\tfrac1p expected steps (the geometric distribution). Gambler's ruin, board-game durations, drug absorption, and queue lengths are all this one linear system with different numbers.

Try it
Try it: steady state and mixing in one go

For M=(0.90.20.10.8)M = \begin{pmatrix}0.9&0.2\\0.1&0.8\end{pmatrix}, find (a) the steady state and (b) the second eigenvalue, and say how much of an initial imbalance survives 1010 steps.

Show the answer

(a) Solve (M−I)v=0(M - I)\mathbf v = \mathbf 0: the first row reads −0.1v1+0.2v2=0-0.1v_1 + 0.2v_2 = 0, so v1:v2=2:1v_1 : v_2 = 2 : 1; normalized to sum 11, the steady state is (23,13)\left(\tfrac23, \tfrac13\right). Check by one multiplication: 0.9⋅23+0.2⋅13=1.8+0.23=230.9\cdot\tfrac23 + 0.2\cdot\tfrac13 = \tfrac{1.8 + 0.2}{3} = \tfrac23 ✓. (b) The eigenvalues add to the trace 1.71.7, and one of them is 11, so λ2=0.7\lambda_2 = 0.7. The deviation from the steady state is multiplied by 0.70.7 each step, so after 1010 steps a fraction (0.7)10≈0.028(0.7)^{10} \approx 0.028 — about 3%3\% — of any initial imbalance remains.

Distributions Step by Step

Tip
n steps is the nth power

Starting from the distribution x0\mathbf x_0, after nn steps the distribution is xn=Mnx0\mathbf x_n = M^n\mathbf x_0, and the entry (Mn)ij(M^n)_{ij} is the probability of being in state ii after nn steps, having started in state jj. For a two-state chain with second eigenvalue λ2\lambda_2 and steady state π\boldsymbol\pi,

xn=π+c λ2 n(1−1),\mathbf x_n = \boldsymbol\pi + c\,\lambda_2^{\,n}\begin{pmatrix}1\\-1\end{pmatrix},

where cc is fixed by x0\mathbf x_0.

Each step conditions on where the chain is now: the chance of landing in ii is ∑jMij xj\sum_j M_{ij}\,x_j, which is row ii of MM times x\mathbf x. Repeating nn times gives MnM^n. For the closed form, the eigenvector of λ2\lambda_2 must have entries summing to 00 (column sums of MM are 11, so MM preserves the total, and λ2≠1\lambda_2\ne1 forces total 00); in two states that is (1,−1)(1, -1). The distance to equilibrium therefore shrinks by the factor ∣λ2∣|\lambda_2| every step.

Example
Worked: two steps by hand

For M=(0.70.40.30.6)M = \begin{pmatrix}0.7&0.4\\0.3&0.6\end{pmatrix}, start in state A: x0=(1,0)\mathbf x_0 = (1, 0). One step: x1=Mx0=(0.7,0.3)\mathbf x_1 = M\mathbf x_0 = (0.7, 0.3), the first column.

Second step: x2=Mx1=(0.7⋅0.7+0.4⋅0.3, 0.3⋅0.7+0.6⋅0.3)=(0.49+0.12, 0.21+0.18)=(0.61,0.39)\mathbf x_2 = M\mathbf x_1 = (0.7\cdot0.7 + 0.4\cdot0.3,\ 0.3\cdot0.7 + 0.6\cdot0.3) = (0.49 + 0.12,\ 0.21 + 0.18) = (0.61, 0.39). Each entry sums over the ways to arrive: in A after two steps means A→A→A (0.7⋅0.70.7\cdot0.7) or A→B→A (0.3⋅0.40.3\cdot0.4). The entries still sum to 11 ✓ — a quick check that the multiplication used rows, not columns.

Example
Worked: the closed form and its check
n123456780.54/7P(in A)
The probability of being in A, step by step from a start in A: it closes in on 4/7 by a factor 0.3 each step.

Same chain, same start. The steady state is π=(47,37)\boldsymbol\pi = \left(\tfrac47, \tfrac37\right) and λ2=0.3\lambda_2 = 0.3. Write x0=(1,0)=(47,37)+37(1,−1)\mathbf x_0 = (1, 0) = \left(\tfrac47, \tfrac37\right) + \tfrac37(1, -1), so c=37c = \tfrac37.

Then

xn=(47,37)+37(0.3)n(1,−1).\mathbf x_n = \left(\tfrac47, \tfrac37\right) + \tfrac37(0.3)^n(1, -1).

Check at n=2n = 2: the first entry is 47+37⋅0.09=4+0.277=4.277=0.61\tfrac47 + \tfrac37\cdot0.09 = \tfrac{4 + 0.27}{7} = \tfrac{4.27}{7} = 0.61 ✓, matching the hand computation. The gap to equilibrium is 37(0.3)n\tfrac37(0.3)^n: about 0.130.13 after one step, 0.01160.0116 after three, and under 10−410^{-4} after seven. This chain forgets its start fast because λ2\lambda_2 is small.

Example
Worked: reading a two-step probability off M²

In the same chain, what is the probability of being in A two steps after starting in B? That is the entry (M2)AB(M^2)_{AB}: row A of MM times column B of MM.

(M2)AB=0.7⋅0.4+0.4⋅0.6=0.28+0.24=0.52(M^2)_{AB} = 0.7\cdot0.4 + 0.4\cdot0.6 = 0.28 + 0.24 = 0.52. The two terms are the two routes: B→A→A (probability 0.4⋅0.70.4\cdot0.7) and B→B→A (0.6⋅0.40.6\cdot0.4). Matrix multiplication is exactly "sum over the intermediate state" — which is why powers of MM answer every multi-step question at once.

Side note
Where it goes wrong: rows for columns

With columns as "from," a start in A is the first column. A common slip multiplies by rows instead and reports x1=(0.7,0.4)\mathbf x_1 = (0.7, 0.4) — entries that sum to 1.11.1, which no probability distribution can do. That is MTx0M^{\mathsf T}\mathbf x_0. (Some books use the other convention, row vectors and rows summing to 11; either works if used consistently, and the sum-to-11 check catches a mix-up at once.)

Try it
Try it: two steps and the long run

For M=(0.50.20.50.8)M = \begin{pmatrix}0.5&0.2\\0.5&0.8\end{pmatrix} and a start in state 2, x0=(0,1)\mathbf x_0 = (0, 1), find x1\mathbf x_1, x2\mathbf x_2, the steady state, and λ2\lambda_2.

Show the answer

x1=Mx0=(0.2,0.8)\mathbf x_1 = M\mathbf x_0 = (0.2, 0.8), the second column. x2=(0.5⋅0.2+0.2⋅0.8, 0.5⋅0.2+0.8⋅0.8)=(0.26,0.74)\mathbf x_2 = (0.5\cdot0.2 + 0.2\cdot0.8,\ 0.5\cdot0.2 + 0.8\cdot0.8) = (0.26, 0.74); the entries sum to 11 ✓. Steady state: (M−I)v=0(M - I)\mathbf v = \mathbf 0 gives −0.5v1+0.2v2=0-0.5v_1 + 0.2v_2 = 0, so v1:v2=2:5v_1 : v_2 = 2 : 5 and π=(27,57)\boldsymbol\pi = \left(\tfrac27, \tfrac57\right). λ2=tr⁡M−1=1.3−1=0.3\lambda_2 = \operatorname{tr}M - 1 = 1.3 - 1 = 0.3. Check with the closed form: x0=(27,57)−27(1,−1)\mathbf x_0 = \left(\tfrac27, \tfrac57\right) - \tfrac27(1, -1), so the first entry of x2\mathbf x_2 is 27−27(0.09)=1.827=0.26\tfrac27 - \tfrac27(0.09) = \tfrac{1.82}{7} = 0.26 ✓.

Absorbing Chains: Where You End Up

Tip
First-step equations for absorption probabilities

Let hih_i be the probability that the chain, started in state ii, is eventually absorbed in a target state TT. Then hT=1h_T = 1, h=0h = 0 at every other absorbing state, and for each transient state

hi=∑jpij hj,h_i = \sum_j p_{ij}\,h_j,

where pijp_{ij} is the probability of stepping from ii to jj. Together with Ei=1+∑jpijEjE_i = 1 + \sum_j p_{ij}E_j for expected times, this answers "where" and "how long."

Condition on the first step. From ii the chain moves to jj with probability pijp_{ij}, and from there its chance of ending in TT is hjh_j — the chain has no memory of how it got to jj. Adding over jj gives the equation. The expected-time equation has the extra 11 for the step just taken. Both are small linear systems, one unknown per transient state.

Example
Worked: the fair gambler's ruin

A gambler with $1\$1 bets $1\$1 at a time on fair coin flips and stops at $0\$0 or $4\$4. What is the chance of reaching $4\$4? With h0=0h_0 = 0 and h4=1h_4 = 1, each middle state satisfies hk=12hk−1+12hk+1h_k = \tfrac12h_{k-1} + \tfrac12h_{k+1}.

That equation says each hkh_k is the average of its neighbors, so the hkh_k lie on a straight line from h0=0h_0 = 0 to h4=1h_4 = 1: hk=k4h_k = \tfrac k4, and h1=14h_1 = \tfrac14. The expected number of bets solves Ek=1+12Ek−1+12Ek+1E_k = 1 + \tfrac12E_{k-1} + \tfrac12E_{k+1} with E0=E4=0E_0 = E_4 = 0, whose solution is Ek=k(4−k)E_k = k(4 - k): E1=3E_1 = 3. Check: E2=4E_2 = 4, and 1+12(E1+E3)=1+12(3+3)=41 + \tfrac12(E_1 + E_3) = 1 + \tfrac12(3 + 3) = 4 ✓. A fair game gives a winning chance equal to the fraction of the total money you start with.

Example
Worked: a biased walk
01232/31/31/32/311
The biased walk: up with probability 2/3, down with 1/3; states 0 and 3 absorb.

A token on 0,1,2,30, 1, 2, 3 steps up with probability 23\tfrac23 and down with 13\tfrac13; 00 and 33 absorb it. Starting at 11, what is the chance of reaching 33? The equations: h1=13h0+23h2=23h2h_1 = \tfrac13h_0 + \tfrac23h_2 = \tfrac23h_2 and h2=13h1+23h3=13h1+23h_2 = \tfrac13h_1 + \tfrac23h_3 = \tfrac13h_1 + \tfrac23.

Substitute the second into the first: h1=23(13h1+23)=29h1+49h_1 = \tfrac23\left(\tfrac13h_1 + \tfrac23\right) = \tfrac29h_1 + \tfrac49, so 79h1=49\tfrac79h_1 = \tfrac49 and h1=47h_1 = \tfrac47. Then h2=13⋅47+23=4+1421=67h_2 = \tfrac13\cdot\tfrac47 + \tfrac23 = \tfrac{4 + 14}{21} = \tfrac67. Check against the gambler's-ruin formula hk=1−(q/p)k1−(q/p)Nh_k = \dfrac{1 - (q/p)^k}{1 - (q/p)^N} with q/p=12q/p = \tfrac12, N=3N = 3: h1=1/27/8=47h_1 = \dfrac{1/2}{7/8} = \tfrac47 ✓. Expected time: E1=1+23E2E_1 = 1 + \tfrac23E_2 and E2=1+13E1E_2 = 1 + \tfrac13E_1 give E1=1+23+29E1E_1 = 1 + \tfrac23 + \tfrac29E_1, so E1=157E_1 = \tfrac{15}{7} and E2=127E_2 = \tfrac{12}{7}.

Side note
Where it goes wrong: dropping the +1

Writing the expected-time equations as E1=23E2E_1 = \tfrac23E_2 and E2=13E1E_2 = \tfrac13E_1 (without the 11 for the step just taken) gives E1=29E1E_1 = \tfrac29E_1, so E1=0E_1 = 0 — the token supposedly finishes instantly. The absorption-probability equations have no +1+1 because they count chances, not steps; the time equations must count the step. A zero or negative expected time is the telltale sign.

Try it
Try it: a short fair walk

A fair walk on 0,1,2,30, 1, 2, 3 (up or down with probability 12\tfrac12 each) is absorbed at 00 and 33. Starting at 11, find the chance of ending at 33 and the expected number of steps.

Show the answer

Absorption: h1=12h0+12h2=12h2h_1 = \tfrac12h_0 + \tfrac12h_2 = \tfrac12h_2 and h2=12h1+12h3=12h1+12h_2 = \tfrac12h_1 + \tfrac12h_3 = \tfrac12h_1 + \tfrac12. Substituting, h1=14h1+14h_1 = \tfrac14h_1 + \tfrac14, so h1=13h_1 = \tfrac13 — the fraction 13\tfrac13 of the way to the top, as the straight-line rule predicts. Time: E1=1+12E2E_1 = 1 + \tfrac12E_2 and E2=1+12E1E_2 = 1 + \tfrac12E_1 (the terms for E0=E3=0E_0 = E_3 = 0 drop out). Substituting, E1=1+12+14E1E_1 = 1 + \tfrac12 + \tfrac14E_1, so 34E1=32\tfrac34E_1 = \tfrac32 and E1=2E_1 = 2. This matches Ek=k(N−k)=1⋅2E_k = k(N - k) = 1\cdot2 ✓.

Proofs & Why It Matters

Tip
Proof: λ = 1 is always an eigenvalue

Let 1=(1,1,…,1)\mathbf 1 = (1, 1, \ldots, 1). Column sums equal 11 means 1TM=1T\mathbf 1^{\mathsf T}M = \mathbf 1^{\mathsf T} — so 11 is an eigenvalue of MTM^{\mathsf T}, and a matrix and its transpose share a characteristic polynomial, hence eigenvalues: 11 is an eigenvalue of MM too.

Moreover no eigenvalue can exceed 11 in magnitude: if Mv=λvM\mathbf v = \lambda\mathbf v, comparing the largest-magnitude entry of both sides shows ∣λ∣≤1|\lambda| \le 1 (each entry of MvM\mathbf v is a weighted average of entries of v\mathbf v). ■\blacksquare Significance: existence of a steady state is thus structural — probability is conserved, so equilibrium is guaranteed; the only question is how fast you get there, which is ∣λ2∣|\lambda_2|'s job.

Side note
The bridge back

Markov chains tie the whole course together: the steady state is an eigenvector (eigenvalues topic), computing MnM^n is diagonalization (powers topic), the entries of MnM^n converge because ∣λ2∣<1|\lambda_2| < 1 (spectral thinking), and expected absorption times are a linear system (row reduction). One applied object exercising every tool in the box — which is exactly why it closes the course.

Going Deeper: Worked Problems

Example
Worked: a three-state weather chain, start to steady state
SRC0.30.30.20.40.70.50.6
The weather chain: sunny (S), rainy (R), cloudy (C), with the probabilities of each move.

Sunny goes to sunny with probability 0.70.7, else rainy; rainy goes to rainy 0.50.5, sunny 0.30.3, cloudy 0.20.2; cloudy goes to sunny 0.40.4, cloudy 0.60.6. Find the long-run fraction of sunny days.

Step 1 — transition matrix (columns from-state, rows to-state): M=(0.70.30.40.30.5000.20.6)M = \begin{pmatrix}0.7&0.3&0.4\\0.3&0.5&0\\0&0.2&0.6\end{pmatrix}; each column sums to 11 ✓.

Step 2 — steady state solves Mv=vM\mathbf v = \mathbf v: from row 2, 0.3s+0.5r=r0.3s + 0.5r = r gives r=0.6sr = 0.6s; from row 3, 0.2r+0.6c=c0.2r + 0.6c = c gives c=0.5r=0.3sc = 0.5r = 0.3s.

Step 3 — normalize: s+0.6s+0.3s=1s + 0.6s + 0.3s = 1, so s=11.9=1019≈52.6%s = \dfrac{1}{1.9} = \dfrac{10}{19} \approx 52.6\% sunny, r=619r = \tfrac{6}{19}, c=319c = \tfrac{3}{19}.

Step 4 — verify row 1: 0.7⋅1019+0.3⋅619+0.4⋅319=7+1.8+1.219=10190.7\cdot\tfrac{10}{19} + 0.3\cdot\tfrac{6}{19} + 0.4\cdot\tfrac{3}{19} = \tfrac{7 + 1.8 + 1.2}{19} = \tfrac{10}{19} ✓. The forecast for a year from now needs no calendar — only this eigenvector.

Example
Worked: expected time to absorb, by first-step equations
01232/32/32/31/31/31/31
The token advances with probability 2/3 and stalls with 1/3; state 3 traps it.

A token starts at 00 and each second moves +1+1 with probability 23\tfrac23 or stays with probability 13\tfrac13; it stops on reaching 33. Expected time to stop?

Step 1 — let EkE_k be the expected remaining time from position kk, with E3=0E_3 = 0.

Step 2 — first-step analysis at each state: Ek=1+23Ek+1+13EkE_k = 1 + \tfrac23E_{k+1} + \tfrac13E_k, so 23Ek=1+23Ek+1\tfrac23E_k = 1 + \tfrac23E_{k+1}, i.e. Ek=32+Ek+1E_k = \tfrac32 + E_{k+1}.

Step 3 — unwind from the end: E2=1.5E_2 = 1.5, E1=3E_1 = 3, E0=4.5E_0 = 4.5.

Step 4 — interpret: each step forward takes 12/3=1.5\tfrac{1}{2/3} = 1.5 expected seconds (geometric distribution), and three steps are needed — linearity of expectation gives 4.54.5 directly, and the linear system confirms it.