Example 2.1. Consider the chain on I={1,2,3} of Figure 1, with transition matrix
P=0021121002121.
Figure 1. The chain of Example 2.1. The loops are the probabilities of staying.
The eigenvalues of P are the roots of the characteristic polynomial det(xI−P). Expanding the determinant along its first row, whose third entry is 0, we get
Hence 0=det(xI−P) exactly when x=1 or x2=−1/4, and the eigenvalues are 1 and ±i/2. They are distinct, so, as in Example 1.4, there is an invertible complex matrix U with P=UDU−1, where D is the diagonal matrix with diagonal entries 1,i/2,−i/2. In Pn=(UDU−1)n each product U−1U between two factors is the identity, so Pn=UDnU−1 for every n≥0. Write ujk and vjk for the entries of U and U−1. Since Dn is diagonal with entries 1,(i/2)n,(−i/2)n, this means that
We then use the values of p11(n) at n=0,1,2 to fix A,B′ and C′. First, p11(0)=1 because P0=I, and p11(1)=p11=0. By the Chapman–Kolmogorov equations,
At n=0,1,2 the factor (1/2)n equals 1,1/2 and 1/4, the cosine cos(nπ/2) equals 1,0 and −1, and the sine sin(nπ/2) equals 0,1 and 0. The three values therefore give
A+B′=1,A+21C′=0,A−41B′=0.
The first equation gives B′=1−A, and the third then becomes A−(1−A)/4=0, that is 5A=1. Hence A=1/5 and B′=4/5, and the second equation gives C′=−2A=−2/5. We get
p11(n)=51+(21)n[54cos2nπ−52sin2nπ].
For an integer n the pair (cos(nπ/2),sin(nπ/2)) depends only on the remainder of n modulo 4: it is (1,0),(0,1),(−1,0) and (0,−1) for the remainders 0, 1, 2 and 3. The bracket therefore takes four values,
More generally, consider a chain with m states, and states i and j.
(i) Compute the eigenvalues μ1,…,μm of the m×m matrix P.
(ii) If the eigenvalues are distinct, then pij(n) has the form
pij(n)=a1+a2μ2n+⋯+amμmn
for some constants a1,…,am, remembering that μ1=1. If an eigenvalue μ is repeated k times, then there is a term (b0+b1n+⋯+bk−1nk−1)μn.
(iii) Complex eigenvalues come in conjugate pairs, and their terms can be written using sines and cosines, as in Example 2.1.
Example 2.2 (Random walk on the vertices of a complete graph). Consider a random walk on the complete graph K4, the vertices of a tetrahedron, with
P=310111101111011110.
The eigenvalues are 1,−1/3,−1/3,−1/3, so the general solution is p11(n)=A+(−1/3)n(a+bn+cn2). However, symmetry can be used: for i=j,pij(n)=(1/3)(1−pii(n)). So
p11(n)=j=1∑p1j(n−1)pj1=31(1−p11(n−1)).
Thus there is just a first-order recurrence equation, whose general solution is of the form p11(n)=A+B(−1/3)n. Since A+B=1 and A+(−1/3)B=0, we have
p11(n)=41+43(−31)n,
and p11(n)→1/4 as n→∞. Do we expect the same for the random walk on the corners of a cube? No: there p11(n) does not tend to a limit, since p11(n)=0 when n is odd.
Example (Random walk on a square). The states are the corners of a square, I={1,2,3,4}, and from each corner the walk moves to each of the two neighbouring corners with probability 1/2, as in Figure 2. The transition matrix is the stochastic matrix
P=021021210210021021210210.
Figure 2. The random walk on a square.
Example (Random walk on Z). Let p∈[0,1]. On I=Z, the walk moves from each state i to i+1 with probability p and to i−1 with probability 1−p, as in Figure 3. Equivalently,
Xn+1=Xn+Yn+1,
where (Yn)n≥1 are independent and identically distributed with P(Yn=1)=p and P(Yn=−1)=1−p. Let X0=0 and p>1/2. By the strong law of large numbers, almost surely
nXn=nY1+⋯+Yn→E[Y1]=p−(1−p)=2p−1>0,
and therefore Xn→+∞ almost surely.
Figure 3. Above, the jumps of the random walk on Z. Below, Xn/n for one path started at X0=0 and n=1,…,400, with the level 2p−1. The slider sets p and the button draws a new path.
Example (Random queue at a counter). A counter serves one customer per unit of time, and customers arrive at random. Let An be the number of customers arriving at time n, with P(An=k)=ak for k=0,1,2,…, where (An)n≥1 are independent and identically distributed. If at time n there are Xn>0 customers in the queue, then Xn+1=(Xn−1)+An+1; if Xn=0, then Xn+1=An+1. In a compact formula,
It is sometimes possible to break a Markov chain into smaller pieces, each of which is relatively easy to understand, and which together give an understanding of the whole. This is done by identifying the communicating classes of the chain. Recall the chain of Example 1.1 of the first post, drawn in Figure 4.
We say that ileads toj, and write i→j, if
Pi(Xn=j for some n≥0)>0.
We say that icommunicates withj, and write i↔j, if both i→j and j→i. A state i is reachable from a state j when pji(n)>0 for some n.
State 4 leads to the states {1, 2, 3, 4, 5, 6, 7} and communicates with the states {4, 5, 6}.
Figure 4. The chain of Example 1.1 of the first post, an instance. Choosing a pad i marks every pad j with i→j, and shades those with i↔j.
For states i,j and k, if i↔j and j↔k then i↔k. From the definition, with n=0, also i↔i. So ↔ satisfies the conditions for an equivalence relation on I, and it partitions I into communicating classes. We say that a class C is closed if
i∈C,i→j⟹j∈C.
A closed class is one from which there is no escape. A state i is absorbing if {i} is a closed class. If C is not closed, then it is open, and there exist i∈C and j∈/C with i→j: the chain can escape from C.
Example 2.5. Find the classes of the chain with transition matrix
and say whether they are open or closed. The classes can be read off the diagram of Figure 5: they are {1,2,3},{4} and {5,6}, with only {5,6} being closed.
Figure 5. The chain of Example 2.5 and its classes.
Example (Gambler’s ruin problem). A gambler wins or loses a coin at each time n=1,2,…: the gambler wins with probability p and loses with probability 1−p, where 0<p<1, and the single bets are independent. For a fixed number N≥2, the game ends when the gambler has N coins (win) or 0 coins (ruin). The number of coins is a chain on I={0,1,…,N} with transition matrix
A chain or transition matrix P in which I is a single class is called irreducible. It is easy to detect: we just have to check that i→j for every i and j.