Skip to content
LeetQuant
QT04 Random Walks and Optimal Stopping

QT04 · Random Walks and Optimal Stopping · Lesson 1 of 4

Random Walks & Markov Chains

Transition matrices, stationary distributions, absorption, recurrence and branching processes.

30 min

Markov chains

A Markov chain moves between states, and the next state depends only on the current one. The transition matrix PP has entries Pij=P(Xn+1=j∣Xn=i)P_{ij} = P(X_{n+1} = j \mid X_n = i), and each row sums to 1. The nn-step transition probabilities are the entries of PnP^n.

A stationary distribution π\pi is a row vector with πP=π\pi P = \pi and entries summing to 1. If the chain is irreducible (every state reachable from every other) and aperiodic, it converges to π\pi from any starting point, and πi\pi_i is the long-run fraction of time spent in state ii.

For two states with switching probabilities aa (from 1 to 2) and bb (from 2 to 1), balancing the flow between them, π1a=π2b\pi_1 a = \pi_2 b, gives

π1=ba+b,π2=aa+b.\pi_1 = \frac{b}{a + b}, \qquad \pi_2 = \frac{a}{a + b} .

Worked example

regime switching

A market is "trending" or "choppy". From trending it moves to choppy with probability 0.2 each day; from choppy to trending with probability 0.3. What fraction of days are trending in the long run, and how long does a trending spell last on average?

Show solution

πtrend=0.30.2+0.3=0.6\pi_{\text{trend}} = \dfrac{0.3}{0.2 + 0.3} = 0.6.

A trending spell ends each day with probability 0.2, so its length is geometric with mean 1/0.2=51/0.2 = 5 days. Another useful fact: the expected time to return to a state is 1/πi1/\pi_i, so starting trending, you next re-enter trending after 1/0.6≈1.671/0.6 \approx 1.67 days on average.

Absorbing chains

Many puzzles end when the chain hits an absorbing state, such as ruin or a target. Let hih_i be the probability of being absorbed in a particular state from state ii, or tit_i the expected number of steps until absorption. Conditioning on one step gives linear equations:

hi=∑jPij hj,ti=1+∑jPij tj,h_i = \sum_j P_{ij}\,h_j, \qquad t_i = 1 + \sum_j P_{ij}\,t_j ,

with h=1h = 1 at the target, h=0h = 0 at the other absorbing states, and t=0t = 0 at all absorbing states. Exploit symmetry to cut down the number of unknowns before solving.

Random walks: recurrence

The simple symmetric random walk on the integers returns to its start with probability 1 (it is recurrent), but the expected return time is infinite. The same is true on the 2D grid. In three or more dimensions the walk is transient: it returns with probability only about 0.34 and then drifts away for ever.

A biased walk on the integers is transient: it drifts off in the direction of its bias. Starting one step above 0 with up-probability p>12p > \tfrac12, the probability of ever reaching 0 is q/pq/p.

Branching processes

Each individual independently has a random number of offspring with generating function G(s)=E[soffspring]G(s) = \mathbb{E}[s^{\text{offspring}}]. Starting from one individual, the extinction probability is the smallest non-negative root of

s=G(s).s = G(s) .

If the mean number of offspring is at most 1, extinction is certain (unless every individual has exactly one child). If it is greater than 1, there is a positive chance the population survives for ever.

Worked example

splitting cells

Each cell either dies (probability 14\tfrac14) or splits into two (probability 34\tfrac34). Starting from one cell, what is the probability the population dies out?

Show solution

G(s)=14+34s2G(s) = \tfrac14 + \tfrac34 s^2. Solving s=14+34s2s = \tfrac14 + \tfrac34 s^2 gives 3s2−4s+1=03s^2 - 4s + 1 = 0, so s=1s = 1 or s=13s = \tfrac13. The extinction probability is the smaller root, 13\tfrac13. As a check, the mean offspring is 1.5>11.5 > 1, so extinction should not be certain.

Knowledge check

A chain's stationary distribution gives state A probability 0.25. Starting in A, what is the expected number of steps until the chain is next in A?

Knowledge check

In a branching process, each individual has 0, 1 or 2 offspring with probabilities 0.3, 0.4 and 0.3. What is the extinction probability starting from one individual?

Knowledge check

An irreducible Markov chain on three states has a transition matrix whose columns, as well as its rows, each sum to 1. What is its stationary distribution?

Practice problems

Finished reading?

Answer the 3 knowledge checks to complete this lesson (0 done).