A Markov chain models a system that hops between a fixed list of states (sunny or rainy, brand A or brand B, city or suburb) with fixed probabilities for each hop. The state of the whole system after k steps is Pk times the starting state, and the question "what happens in the long run?" turns out to be an eigenvector question: the long-run distribution is an eigenvector of P for the eigenvalue 1.
Probability vectors and stochastic matrices
Definition
Probability vector and stochastic matrix
A probability vector is a vector with nonnegative entries that add up to 1.
A stochastic matrix is a square matrix whose columns are all probability vectors.
Think of entry pij of a stochastic matrix P as the probability of moving to state ifrom state j in one step. Column j lists where state j goes, so it must add up to 1.
For example, suppose each year 90% of city residents stay in the city and 10% move to the suburbs, while 20% of suburban residents move to the city and 80% stay. With state 1 = city and state 2 = suburbs,
P=[0.90.10.20.8].
The chain
A Markov chain is a sequence of probability vectors x0,x1,x2,… together with a stochastic matrix P such that
xk+1=Pxk(k=0,1,2,…).
The vector xk is the state vector after k steps: its entries are the fractions of the population (or the probabilities) in each state. Unrolling the recursion gives xk=Pkx0. Multiplying a probability vector by a stochastic matrix always gives another probability vector, so every xk is a probability vector.
Worked example: Following the chain
In the city–suburb model, everyone starts in the city: x0=(1,0). Find x1 and x2.
After two years, 83% live in the city and 17% in the suburbs. Keep going and you get x3≈(0.781,0.219), x4≈(0.747,0.253), and the numbers settle down toward (2/3,1/3).
Steady-state vectors
If the chain settles down to some vector q, then applying P must leave q unchanged.
Definition
Steady-state vector
A steady-state vector (or equilibrium vector) for a stochastic matrix P is a probability vector q with
Pq=q.
In the language of this unit, q is an eigenvector of P with eigenvalue 1, scaled so its entries add up to 1. Every stochastic matrix has 1 as an eigenvalue: the rows of PT add up to 1, so PT(1,1,…,1)=(1,1,…,1), and P and PT have the same eigenvalues.
To find q:
Solve (P−I)x=0 and pick any nonzero solution.
Divide it by the sum of its entries.
Worked example: A 2 × 2 steady state
Find the steady-state vector of P=[0.90.10.20.8].
P−I=[−0.10.10.2−0.2]. Both rows say x1=2x2, so (2,1) is a solution. Its entries add up to 3, so
q=[2/31/3].
Check: 0.9⋅32+0.2⋅31=31.8+0.2=32. In the long run, two thirds of the population lives in the city.
Worked example: A 3 × 3 steady state
Find the steady-state vector of P=0.50.30.20.20.800.30.30.4.
First check that each column adds up to 1: 0.5+0.3+0.2, 0.2+0.8+0, 0.3+0.3+0.4. Now solve (P−I)x=0:
The third equation gives x1=3x3. Substituting into the first: −1.5x3+0.2x2+0.3x3=0, so x2=6x3. (The second equation checks: 0.9x3−1.2x3+0.3x3=0.) Taking x3=1 gives (3,6,1), whose entries add up to 10:
q=0.30.60.1.
Why the chain converges
Definition
Regular stochastic matrix
A stochastic matrix P is regular if some power Pk has all entries strictly positive.
The matrix in the 3×3 example has a zero entry, but P2 does not (its (3,2) entry is 0.2⋅0.2+0⋅0.8+0.4⋅0=0.04), so it is regular.
Convergence theorem
If P is a regular stochastic matrix, then P has a unique steady-state vector q, and for every starting probability vector x0, the chain xk=Pkx0 converges to q.
Eigenvectors show why. For the city–suburb matrix, the trace is 1.7, so the eigenvalues are 1 and 0.7. An eigenvector for 0.7 is (1,−1). Write the starting vector in the eigenvector basis:
The eigenvalue-1 part never changes, and the other part shrinks by a factor of 0.7 every step, so xk→q. The graph shows the city fraction 32+31(0.7)k approaching 32.
The fraction of people in the city after k years. The gap to the steady state 2/3 shrinks by the second eigenvalue, 0.7, each year.Open in grapher →
Tip
For a 2×2 stochastic matrix [1−aab1−b], the eigenvalues are 1 and 1−a−b (from the trace), and the steady state is q=a+b1[ba]. The closer the second eigenvalue is to 0, the faster the chain converges.
Common mistake
Without regularity, the chain need not settle down. For P=[0110], the steady state is (0.5,0.5), but starting from (1,0) the chain jumps back and forth between (1,0) and (0,1) forever. Every power of P has zeros, so P is not regular. (Its other eigenvalue is −1, which never shrinks.) Also remember that in this course the columns of P add up to 1; some books use rows instead and multiply on the other side.
Practice
Practice 1
Which matrix is stochastic?
Practice 2
Let P=[0.60.40.30.7] and x0=(0.5,0.5). Find x1=Px0.
Enter a point like (2, -3)
Practice 3
Find the steady-state vector of P=[0.60.40.30.7].
Enter a point like (2, -3)
Practice 4
The matrix P=[0.60.40.30.7] has 1 as an eigenvalue. Find its other eigenvalue.
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Practice 5
In a town, if a day is sunny, the next day is sunny with probability 0.8. If a day is rainy, the next day is sunny with probability 0.4. Today is sunny. What is the probability that the day after tomorrow is sunny?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Practice 6
In the weather model of the previous problem, what fraction of days are sunny in the long run?
Enter a number. Fractions like 3/4 and sqrt(2) are OK.
Practice 7
Find the steady-state vector of P=0.70.20.10.10.80.10.20.20.6.