Alessandro Palliccia

Stochastic Dynamical Models

Calculation of nn-step transition probabilities and class structure

1,159 words,

The nn-step transition probabilities pij(n)p^{(n)}_{ij} of a chain with finitely many states can be computed from the eigenvalues of its transition matrix. The states of a chain split into communicating classes, which break the chain into smaller pieces.

Example: a three-state Markov chain

Example 2.1. Consider the chain on I={1,2,3}{I = \{1, 2, 3\}} of Figure 1, with transition matrix

P=(0100121212012).P = \begin{pmatrix} 0 & 1 & 0 \\[2pt] 0 & \frac12 & \frac12 \\[2pt] \frac12 & 0 & \frac12 \end{pmatrix}.
½½1½½123

Figure 1. The chain of Example 2.1. The loops are the probabilities of staying.

The eigenvalues of PP are the roots of the characteristic polynomial det⁡(xI−P).{\det(xI - P).} Expanding the determinant along its first row, whose third entry is 0, we get

det⁡(xI−P)=det⁡(x−100x−12−12−120x−12)=xdet⁡(x−12−120x−12)−(−1)det⁡(0−12−12x−12)=x(x−12)2−14.\begin{aligned} \det(xI - P) &= \det \begin{pmatrix} x & -1 & 0 \\[2pt] 0 & x - \frac12 & -\frac12 \\[2pt] -\frac12 & 0 & x - \frac12 \end{pmatrix} \\[4pt] &= x \det \begin{pmatrix} x - \frac12 & -\frac12 \\[2pt] 0 & x - \frac12 \end{pmatrix} - (-1) \det \begin{pmatrix} 0 & -\frac12 \\[2pt] -\frac12 & x - \frac12 \end{pmatrix} \\[4pt] &= x \big( x - \tfrac12 \big)^2 - \tfrac14. \end{aligned}

Multiplying out and collecting the factor x−1,{x - 1,}

x(x−12)2−14=x3−x2+14x−14=x2(x−1)+14(x−1)=14(x−1)(4x2+1).x \big( x - \tfrac12 \big)^2 - \tfrac14 = x^3 - x^2 + \tfrac14 x - \tfrac14 = x^2 (x - 1) + \tfrac14 (x - 1) = \tfrac14 (x - 1)(4x^2 + 1).

Hence 0=det⁡(xI−P){0 = \det(xI - P)} exactly when x=1{x = 1} or x2=−1/4,{x^2 = -1/4,} and the eigenvalues are 1 and ±i/2.{\pm i/2.} They are distinct, so, as in Example 1.4, there is an invertible complex matrix UU with P=UDU−1,{P = U D U^{-1},} where DD is the diagonal matrix with diagonal entries 1,i/2,−i/2.{1, i/2, -i/2.} In Pn=(UDU−1)n{P^n = (U D U^{-1})^n} each product U−1UU^{-1} U between two factors is the identity, so Pn=UDnU−1{P^n = U D^n U^{-1}} for every n≥0.{n \ge 0.} Write ujku_{jk} and vjkv_{jk} for the entries of UU and U−1.U^{-1}. Since DnD^n is diagonal with entries 1,(i/2)n,(−i/2)n,{1, (i/2)^n, (-i/2)^n,} this means that

p11(n)=(UDnU−1)11=∑k=13u1k(Dn)kkvk1=A+B(i/2)n+C(−i/2)n,p^{(n)}_{11} = (U D^n U^{-1})_{11} = \sum_{k=1}^{3} u_{1k} (D^n)_{kk} v_{k1} = A + B (i/2)^n + C (-i/2)^n,

with the constants A=u11v11,{A = u_{11} v_{11},} B=u12v21{B = u_{12} v_{21}} and C=u13v31.{C = u_{13} v_{31}.} By Euler’s formula eiθ=cos⁡θ+isin⁡θ,{e^{i\theta} = \cos\theta + i \sin\theta,} we have ±i/2=(1/2)e±iπ/2,{\pm i/2 = (1/2) e^{\pm i\pi/2},} and we make the substitution

(±i/2)n=(1/2)ne±inπ/2=(1/2)n(cos⁡(nπ/2)±isin⁡(nπ/2)).(\pm i/2)^n = (1/2)^n e^{\pm i n \pi / 2} = (1/2)^n \big( \cos(n\pi/2) \pm i \sin(n\pi/2) \big).

Substituting it into p11(n)p^{(n)}_{11} and collecting the terms in the cosine and in the sine, we get, for the constants B′=B+C{B' = B + C} and C′=i(B−C),{C' = i (B - C),}

p11(n)=A+(1/2)n((B+C)cos⁡(nπ/2)+i(B−C)sin⁡(nπ/2))=A+(1/2)n(B′cos⁡(nπ/2)+C′sin⁡(nπ/2)).\begin{aligned} p^{(n)}_{11} &= A + (1/2)^n \big( (B + C) \cos(n\pi/2) + i (B - C) \sin(n\pi/2) \big) \\ &= A + (1/2)^n \big( B' \cos(n\pi/2) + C' \sin(n\pi/2) \big). \end{aligned}

We then use the values of p11(n)p^{(n)}_{11} at n=0,1,2{n = 0, 1, 2} to fix A,A, B′B' and C′.C'. First, p11(0)=1{p^{(0)}_{11} = 1} because P0=I,{P^0 = I,} and p11(1)=p11=0.{p^{(1)}_{11} = p_{11} = 0.} By the Chapman–Kolmogorov equations,

p11(2)=p11p11+p12p21+p13p31=0⋅0+1⋅0+0⋅12=0.p^{(2)}_{11} = p_{11} p_{11} + p_{12} p_{21} + p_{13} p_{31} = 0 \cdot 0 + 1 \cdot 0 + 0 \cdot \tfrac12 = 0.

At n=0,1,2{n = 0, 1, 2} the factor (1/2)n(1/2)^n equals 1,1, 1/21/2 and 1/4,1/4, the cosine cos⁡(nπ/2)\cos(n\pi/2) equals 1,1, 00 and −1,-1, and the sine sin⁡(nπ/2)\sin(n\pi/2) equals 0,0, 11 and 0.0. The three values therefore give

A+B′=1,A+12C′=0,A−14B′=0.A + B' = 1, \qquad A + \tfrac12 C' = 0, \qquad A - \tfrac14 B' = 0.

The first equation gives B′=1−A,{B' = 1 - A,} and the third then becomes A−(1−A)/4=0,{A - (1 - A)/4 = 0,} that is 5A=1.{5A = 1.} Hence A=1/5{A = 1/5} and B′=4/5,{B' = 4/5,} and the second equation gives C′=−2A=−2/5.{C' = -2A = -2/5.} We get

p11(n)=15+(12)n[45cos⁡nπ2−25sin⁡nπ2].p^{(n)}_{11} = \frac15 + \Big( \frac12 \Big)^n \Big[ \frac45 \cos \frac{n\pi}{2} - \frac25 \sin \frac{n\pi}{2} \Big].

For an integer nn the pair (cos⁡(nπ/2),sin⁡(nπ/2)){(\cos(n\pi/2), \sin(n\pi/2))} depends only on the remainder of nn modulo 4: it is (1,0),(1, 0), (0,1),(0, 1), (−1,0)(-1, 0) and (0,−1)(0, -1) for the remainders 0, 1, 2 and 3. The bracket therefore takes four values,

45cos⁡nπ2−25sin⁡nπ2={−4/5if n≡0(mod4),−2/5if n≡1(mod4),−4/5if n≡2(mod4),−2/5if n≡3(mod4),\frac45 \cos \frac{n\pi}{2} - \frac25 \sin \frac{n\pi}{2} = \begin{cases} \phantom{-}4/5 & \text{if } n \equiv 0 \pmod 4, \\ -2/5 & \text{if } n \equiv 1 \pmod 4, \\ -4/5 & \text{if } n \equiv 2 \pmod 4, \\ \phantom{-}2/5 & \text{if } n \equiv 3 \pmod 4, \end{cases}

and the second term of p11(n)p^{(n)}_{11} has absolute value at most (4/5)2−n:{(4/5) 2^{-n}{:}} it is exponentially decaying. Since 5≡1{5 \equiv 1} and 10≡2{10 \equiv 2} modulo 4, we have

p11(5)=15−25⋅132=15−180=316,p11(10)=15−45⋅11024=15−11280=51256,p^{(5)}_{11} = \frac15 - \frac25 \cdot \frac{1}{32} = \frac15 - \frac{1}{80} = \frac{3}{16}, \qquad p^{(10)}_{11} = \frac15 - \frac45 \cdot \frac{1}{1024} = \frac15 - \frac{1}{1280} = \frac{51}{256},

and ∣p11(n)−1/5∣≤(4/5)2−n<2−n{|p^{(n)}_{11} - 1/5| \le (4/5) 2^{-n} < 2^{-n}} for every n≥0.{n \ge 0.} Figure 2 draws these values.

01/510123456789101112131415163/1651/256n

Figure 2. p11(n)p^{(n)}_{11} for Example 2.1 and n=0,1,…,16,{n = 0, 1, \dots, 16,} with the level 1/51/5 and the band 1/5±2−n.{1/5 \pm 2^{-n}.} The values at n=5{n = 5} and n=10{n = 10} are marked.

More generally, consider a chain with mm states, and states ii and j.j.
(i) Compute the eigenvalues μ1,…,μm{\mu_1, \dots, \mu_m} of the m×m{m \times m} matrix P.P.
(ii) If the eigenvalues are distinct, then pij(n)p^{(n)}_{ij} has the form pij(n)=a1+a2μ2n+⋯+amμmn{p^{(n)}_{ij} = a_1 + a_2 \mu_2^n + \dots + a_m \mu_m^n} for some constants a1,…,am,{a_1, \dots, a_m,} remembering that μ1=1.{\mu_1 = 1.} If an eigenvalue μ\mu is repeated kk times, then there is a term (b0+b1n+⋯+bk−1nk−1)μn.{(b_0 + b_1 n + \dots + b_{k-1} n^{k-1}) \mu^n.}
(iii) Complex eigenvalues come in conjugate pairs, and their terms can be written using sines and cosines, as in Example 2.1.

Sometimes there is a quicker way, as the next example shows.

Example: use of symmetry

Example 2.2 (Random walk on the vertices of a complete graph). Consider a random walk on the complete graph K4,K_4, the vertices of a tetrahedron, with

P=13(0111101111011110).P = \frac13 \begin{pmatrix} 0 & 1 & 1 & 1 \\ 1 & 0 & 1 & 1 \\ 1 & 1 & 0 & 1 \\ 1 & 1 & 1 & 0 \end{pmatrix}.

The eigenvalues are 1,−1/3,−1/3,−1/3,{1, -1/3, -1/3, -1/3,} so the general solution is p11(n)=A+(−1/3)n(a+bn+cn2).{p^{(n)}_{11} = A + (-1/3)^n (a + bn + cn^2).} However, symmetry can be used: for i≠j,{i \neq j,} pij(n)=(1/3)(1−pii(n)).{p^{(n)}_{ij} = (1/3)(1 - p^{(n)}_{ii}).} Indeed, by symmetry the three entries pij(n)p^{(n)}_{ij} with j≠i{j \neq i} are equal, and the row ii of PnP^n sums to 1. So

p11(n)=∑j≠1p1j(n−1)pj1=13(1−p11(n−1)).p^{(n)}_{11} = \sum_{j \neq 1} p^{(n-1)}_{1j} p_{j1} = \frac13 \big( 1 - p^{(n-1)}_{11} \big).

Thus there is just a first-order recurrence equation, whose general solution is of the form p11(n)=A+B(−1/3)n.{p^{(n)}_{11} = A + B(-1/3)^n.} Since A+B=1{A + B = 1} and A+(−1/3)B=0,{A + (-1/3) B = 0,} we have

p11(n)=14+34(−13)n,p^{(n)}_{11} = \frac14 + \frac34 \Big( -\frac13 \Big)^n,

and p11(n)→1/4{p^{(n)}_{11} \to 1/4} as n→∞.{n \to \infty.} Do we expect the same for the random walk on the corners of a cube? No: there p11(n)p^{(n)}_{11} does not tend to a limit, since p11(n)=0{p^{(n)}_{11} = 0} when nn is odd.

123401/41012345678910n

Figure 3. The random walk of Example 2.2, each line a jump in either direction with probability 1/3,1/3, and p11(n)=1/4+(3/4)(−1/3)n{p^{(n)}_{11} = 1/4 + (3/4)(-1/3)^n} for n=0,1,…,10{n = 0, 1, \dots, 10} with the level 1/4.1/4.

Random walks and a queue

Example (Random walk on a square). The states are the corners of a square, I={1,2,3,4},{I = \{1, 2, 3, 4\},} and from each corner the walk moves to each of the two neighbouring corners with probability 1/2,1/2, as in Figure 4. The transition matrix is the stochastic matrix

P=(012012120120012012120120).P = \begin{pmatrix} 0 & \frac12 & 0 & \frac12 \\[2pt] \frac12 & 0 & \frac12 & 0 \\[2pt] 0 & \frac12 & 0 & \frac12 \\[2pt] \frac12 & 0 & \frac12 & 0 \end{pmatrix}.
½½½½½½½½1234

Figure 4. The random walk on a square.

Example (Random walk on Z\mathbb{Z}). Let p∈[0,1].{p \in [0, 1].} On I=Z,{I = \mathbb{Z},} the walk moves from each state ii to i+1{i + 1} with probability pp and to i−1{i - 1} with probability 1−p,{1 - p,} as in Figure 5. Equivalently,

Xn+1=Xn+Yn+1,X_{n+1} = X_n + Y_{n+1},

where (Yn)n≥1(Y_n)_{n \ge 1} are independent and identically distributed with P(Yn=1)=p{P(Y_n = 1) = p} and P(Yn=−1)=1−p.{P(Y_n = -1) = 1 - p.} Let X0=0{X_0 = 0} and p>1/2.{p > 1/2.} By the strong law of large numbers, almost surely

Xnn=Y1+⋯+Ynn→E[Y1]=p−(1−p)=2p−1>0,\frac{X_n}{n} = \frac{Y_1 + \dots + Y_n}{n} \to E[Y_1] = p - (1 - p) = 2p - 1 > 0,

and therefore Xn→+∞{X_n \to +\infty} almost surely.

pp1 − p1 − p1 − pi − 1ii + 1i + 2

Figure 5. Above, the jumps of the random walk on Z.\mathbb{Z}. Below, Xn/nX_n/n for one path started at X0=0{X_0 = 0} and n=1,…,400,{n = 1, \dots, 400,} with the level 2p−1.{2p - 1.} The slider sets pp 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 AnA_n be the number of customers arriving at time n,n, with P(An=k)=ak{P(A_n = k) = a_k} for k=0,1,2,…,{k = 0, 1, 2, \dots,} where (An)n≥1(A_n)_{n \ge 1} are independent and identically distributed. If at time nn there are Xn>0{X_n > 0} customers in the queue, then Xn+1=(Xn−1)+An+1;{X_{n+1} = (X_n - 1) + A_{n+1};} if Xn=0,{X_n = 0,} then Xn+1=An+1.{X_{n+1} = A_{n+1}.} In a compact formula,

Xn+1=(Xn−1)++An+1,X_{n+1} = (X_n - 1)^+ + A_{n+1},

Indeed, (Xn−1)+=max⁡(Xn−1,0){(X_n - 1)^+ = \max(X_n - 1, 0)} is Xn−1{X_n - 1} when Xn>0{X_n > 0} and 0 when Xn=0,{X_n = 0,} and, with X0=i{X_0 = i} fixed, the recursion is the construction Xn+1=F(Xn,An+1){X_{n+1} = F(X_n, A_{n+1})} of the previous post with F(j,a)=(j−1)++a,{F(j, a) = (j - 1)^+ + a,} so (Xn)n≥0(X_n)_{n \ge 0} is Markov(δi,P)\mathrm{Markov}(\delta_i, P) for a transition matrix P.P.

Class structure

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, drawn in Figure 6.

We say that ii leads to j,j, and write i→j,{i \to j,} if

Pi(Xn=j for some n≥0)>0.P_i(X_n = j \text{ for some } n \ge 0) > 0.

We say that ii communicates with j,j, and write i↔j,{i \leftrightarrow j,} if both i→j{i \to j} and j→i.{j \to i.} A state ii is reachable from a state jj when pji(n)>0{p^{(n)}_{ji} > 0} for some n.n.

1234567

State 4 leads to the states {1, 2, 3, 4, 5, 6, 7} and communicates with the states {4, 5, 6}.

Figure 6. The chain of Example 1.1, an instance. Choosing a pad ii marks every pad jj with i→j,{i \to j,} and shades those with i↔j.{i \leftrightarrow j.}

Closed classes

For states i,i, jj and k,k, if i↔j{i \leftrightarrow j} and j↔k{j \leftrightarrow k} then i↔k.{i \leftrightarrow k.} From the definition, with n=0,{n = 0,} also i↔i.{i \leftrightarrow i.} So ↔\leftrightarrow satisfies the conditions for an equivalence relation on I,I, and it partitions II into communicating classes. We say that a class CC is closed if

i∈C, i→j  ⟹  j∈C.i \in C, \ i \to j \implies j \in C.

A closed class is one from which there is no escape. A state ii is absorbing if {i}\{i\} is a closed class. If CC is not closed, then it is open, and there exist i∈C{i \in C} and j∉C{j \notin C} with i→j:{i \to j{:}} the chain can escape from C.C.

Example 2.5. Find the classes of the chain with transition matrix

P=(1212000000100013001313000012120000001000010)P = \begin{pmatrix} \frac12 & \frac12 & 0 & 0 & 0 & 0 \\[2pt] 0 & 0 & 1 & 0 & 0 & 0 \\[2pt] \frac13 & 0 & 0 & \frac13 & \frac13 & 0 \\[2pt] 0 & 0 & 0 & \frac12 & \frac12 & 0 \\[2pt] 0 & 0 & 0 & 0 & 0 & 1 \\[2pt] 0 & 0 & 0 & 0 & 1 & 0 \end{pmatrix}

and say whether they are open or closed. The classes can be read off the diagram of Figure 7: they are {1,2,3},{\{1, 2, 3\},} {4}\{4\} and {5,6},{\{5, 6\},} with only {5,6}\{5, 6\} being closed.

openopenclosed½½½1⅓⅓⅓½11123456

Figure 7. 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,…:{n = 1, 2, \dots{:}} the gambler wins with probability pp and loses with probability 1−p,{1 - p,} where 0<p<1,{0 < p < 1,} and the single bets are independent. For a fixed number N≥2,{N \ge 2,} the game ends when the gambler has NN coins (win) or 0 coins (ruin). The number of coins is a chain on I={0,1,…,N}{I = \{0, 1, \dots, N\}} with transition matrix

P=(1000⋯0001−p0p0⋯00001−p0p⋯000⋮⋱⋱⋱⋮0000⋯1−p0p0000⋯001),P = \begin{pmatrix} 1 & 0 & 0 & 0 & \cdots & 0 & 0 & 0 \\ 1 - p & 0 & p & 0 & \cdots & 0 & 0 & 0 \\ 0 & 1 - p & 0 & p & \cdots & 0 & 0 & 0 \\ \vdots & & \ddots & \ddots & \ddots & & & \vdots \\ 0 & 0 & 0 & 0 & \cdots & 1 - p & 0 & p \\ 0 & 0 & 0 & 0 & \cdots & 0 & 0 & 1 \end{pmatrix},

whose rows and columns are indexed by 0,1,…,N.{0, 1, \dots, N.} The classes of states are {0},{\{0\},} {N}\{N\} and {1,…,N−1}.{\{1, \dots, N - 1\}.} Indeed, for 1≤i≤j≤N−1,{1 \le i \le j \le N - 1,}

pij(j−i)=p j−i>0,pji(j−i)=(1−p)j−i>0,p^{(j-i)}_{ij} = p^{\, j-i} > 0, \qquad p^{(j-i)}_{ji} = (1 - p)^{j-i} > 0,

because the only sequence of j−i{j - i} steps from ii to jj moves up at every step, and the only one from jj to ii moves down at every step. So all the states 1,…,N−1{1, \dots, N - 1} communicate.

11ppppp1 − p1 − p1 − p1 − p1 − p0123456

p24(2) = p2 = 0.3600, p42(2) = (1 − p)2 = 0.1600

Figure 8. The gambler’s ruin chain with its classes. The sliders set N,N, pp and two states 1≤i≤j≤N−1;{1 \le i \le j \le N - 1;} the paths of j−i{j - i} steps between them are marked with their probabilities.

Irreducibility

A chain or transition matrix PP in which II is a single class is called irreducible. It is easy to detect: we just have to check that i→j{i \to j} for every ii and j.j.

Period of a state

The last definition uses the entries pii(n)p^{(n)}_{ii} of the nn-step transition matrix.

Definition (Period). The period of a state ii is

d(i)=gcd⁡{n≥1:pii(n)>0},d(i) = \gcd \{ n \ge 1 : p^{(n)}_{ii} > 0 \},

the greatest common divisor of the set, when this set is nonempty.

Definition (Aperiodic state). A state ii is aperiodic if d(i)=1.{d(i) = 1.}