Worked examples — Stochastic processes — Markov chains, steady-state, random walks
Before we start, a quick reminder of the two objects we keep using, in plain words:
We will also need two ways of summarising a random number, so define them once, now, before any calculation uses them:
The scenario matrix
Every problem in this chapter lives in exactly one of these cells. The worked examples that follow are tagged with the cell they cover, so together they fill the whole grid.
| # | Case class | What makes it tricky | Covered by |
|---|---|---|---|
| A | Standard steady-state (2–3 states, nice numbers) | Solve + normalise | Ex 1 |
| B | Sign / direction of drift in a random walk () | Mean is no longer — which way does it lean? | Ex 2 |
| C | Zero / degenerate input: an absorbing state () | A row that "traps" you — steady-state can be non-unique | Ex 3 |
| D | Limiting behaviour: what does approach, and how fast? | The second eigenvalue controls the speed | Ex 4 |
| E | Periodic / non-convergent chain | Distribution oscillates forever, exists but is never reached | Ex 5 |
| F | Real-world word problem (customer/machine model) | Translate English → matrix, then interpret the answer | Ex 6 |
| G | Gambler's ruin, biased () + expected duration | The linear formula breaks; a ratio formula takes over | Ex 7 |
| H | Exam twist: expected number of visits / first-passage | First-step analysis on a different quantity | Ex 8 |
Example 1 — Cell A: standard 3-state steady-state
Forecast: guess first — the middle pad is reachable from everyone and feeds everyone. Do you expect it to hold more or less probability than the ends? Write your guess.
Recall The setup: what equation are we solving?
with . This is the balance equation "inflow = there" for each column.
Step 1. Write the three balance equations, one per column of (a column collects everyone who flows into that state). Why this step? Each equation says "probability sitting in state equals total probability flowing in from all ", which is exactly .
Step 2. Simplify equation 1: . By symmetry, equation 3 gives . Why this step? Move the term to the left; the algebra collapses because the chain is symmetric left-to-right.
Step 3. Normalise: , so . Why this step? The three fractions must add to certainty (); that pins down the scale.
The middle pad holds more — good if you guessed that.
Example 2 — Cell B: biased random walk, which way does it drift?
Forecast: , so it leans right. But by how much compared to the random wobble? Guess whether the drift or the spread wins after 100 steps.
How to read the figure below. The horizontal axis is the number of steps ; the vertical axis is the particle's position . The three thin coloured lines are individual random journeys. The thick navy line is the drift — the average position, climbing steadily to the labelled point . The two dashed navy lines are the spread band ; the shaded orange region between them is where a typical path lives. The visual lesson: the drift line races up in a straight line while the shaded band only fans out slowly (like ), so by step the drift () has clearly overtaken the wobble ().

Step 1. One step has mean . Why this step? By the definition of expectation above, the mean of a single move = each outcome times its chance. This nonzero mean is the drift — the constant lean the parent note's symmetric case did not have.
Step 2. . Why this step? Expectation is additive; identical steps make it times one step. The drift grows linearly in — this is the steep straight navy line in the figure.
Step 3. Variance of one step, using : first , so . Why this step? This is exactly the variance definition we set up above. Because steps are independent, variances add: .
Step 4. Spread . Why this step? The typical wobble is the standard deviation (square root of variance) — the half-width of the shaded band in the figure. Compare: drift vs wobble — the drift wins, so the particle is reliably to the right of the origin.
Example 3 — Cell C: an absorbing state (degenerate row)
Forecast: state is perfectly symmetric between and ( each). Guess the absorption probability before reading.
Step 1. Let . First-step analysis: Why this step? From state , condition on the first move (memorylessness). Going straight to succeeds with prob ; going to fails; staying in leaves us with the same unknown .
Step 2. Solve: . Why this step? Collect the terms; the self-loop moves to the left. Symmetry confirmed: .
Step 3. Stationary distributions. Solving here gives infinitely many: any with works. Why this step? Both absorbing states are stationary on their own; any mixture of them is too. This is the non-uniqueness the parent warned about — the chain is reducible (you cannot get from to ).
Example 4 — Cell D: how fast does converge?
Forecast: every stochastic matrix has eigenvalue . The other one decides speed. Guess: closer to means faster or slower convergence?
Step 1. Eigenvalues solve : . Why this step? The determinant is zero exactly when squashes some vector to zero — i.e. that vector is an eigenvector.
Step 2. Expand: . Roots: and . Why this step? Factor the quadratic. As promised, ; the mover is .
Step 3. Treating the decay as , we want : Why this step? Take logs to unstick from the exponent. So steps already bring the total-variation distance below .
Example 5 — Cell E: a periodic chain that never converges
Forecast: this chain flips deterministically . A stationary still exists — but will a lopsided start ever settle? Guess yes/no.
Step 1. Solve : , so . With : . Why this step? The balance equation still has a solution — a stationary distribution existing does not guarantee convergence.
Step 2. Now iterate from : Why this step? Multiplying by just swaps the two entries. It oscillates with period forever, never approaching .
Example 6 — Cell F: real-world word problem
Forecast: stickiness is high, but win-back is modest. Guess the long-run subscribed fraction — above or below ?
Step 1. Translate the English into a matrix. States: (subscribed), (cancelled). Why this step? Row reads "stay , leave "; row reads "return , stay gone ". Each row sums to ✔ — that sum is the sanity check that the English translated correctly into a valid transition matrix.
Step 2. Write the balance equation for the column: . Why this step? Inflow into = the who stayed subscribed plus the of cancelled who returned; in steady state this must equal the mass sitting in .
Step 3. Rearrange: . Why this step? Collect the terms on the left; the leftover relates the two unknowns by a clean ratio .
Step 4. Normalise: . Why this step? The two fractions must add to (every customer is in exactly one state); that fixes the scale.
Step 5. Interpret in plain English: in the long run two out of every three customers () are subscribed at any given month, regardless of how the company started. Why this step? The problem asked for a real-world fraction, so we translate the vector back to words — the point of a word problem.
Example 7 — Cell G: biased gambler's ruin + expected duration
Forecast: with a favourable game (), reaching from should be higher than the fair-game answer . Guess a number.
Step 1. Set up the first-step equation. Let . Conditioning on the first bet: Why this step? Memorylessness: after one bet the game restarts at (win) or (loss). The boundaries are certain — at you have already lost, at you have already won.
Step 2. Rearrange into a gap relation. Writing and using : Why this step? Move to the right and group. The successive gaps shrink by the constant factor — a geometric sequence, not the constant gaps that gave the fair-game linear rule.
Step 3. Sum the geometric gaps from to . Since and fixes , the standard result drops out: Why this step? A finite geometric sum ; the same appears top and bottom and cancels, leaving the clean ratio.
Step 4. Plug , , : Why this step? Direct substitution. Answer — the favourable edge helps, as forecast.
Step 5 — part (b). Why fails: the fair-game derivation assumed equal gaps , which forces a straight line . That equality only holds when (so ). With bias , the gaps form a geometric sequence, curving upward toward the favourable end — the walk reaches the far goal more easily than "linear" would predict. Why this step? It pinpoints the exact assumption that breaks, so you know when each formula is legal.
Example 8 — Cell H: exam twist — expected number of steps (first-passage)
Forecast: this asks about duration, not which end. Guess: a few steps, or many?
Step 1. Let = expected steps to absorption from state . First-step analysis on the count: Why this step? Every move costs one step (the ""), then from the new state we still expect more. Absorbing states cost (already done). This is first-step analysis applied to a duration instead of a probability — the exam twist.
Step 2. Write the two interior equations (): Why this step? Substitute the boundary values ; two equations, two unknowns.
Step 3. Solve. From the first, . Substitute into the second: Why this step? Linear substitution. By symmetry makes sense — states and are mirror images.
Active Recall
Recall Which cell asks for the
second eigenvalue, and why? Cell D (convergence speed). The largest eigenvalue gives ; governs how fast the total-variation distance to decays.
Recall In a biased random walk, which grows like
and which like ? Drift (mean) grows like ; spread (std dev) grows like . For large the drift dominates.
Recall Why is
wrong for a biased gambler? It assumes equal gaps , true only when . With bias the gaps are geometric with ratio , giving .
Recall Absorbing states make a chain's stationary distribution…
Non-unique (the chain is reducible): any mixture of the absorbing states is stationary.
Recall Expected absorption time for a symmetric walk from
on ? .
Connections
- Parent topic (the machinery these examples apply)
- Linear Algebra — Eigenvalues and Eigenvectors (Ex 4: and convergence rate)
- Perron–Frobenius Theorem (Ex 3 & 5: uniqueness fails for reducible / periodic chains)
- Law of Total Probability (first-step analysis in Ex 3, 7, 8)
- Central Limit Theorem (Ex 2: biased walk → Gaussian around drift )
- Diffusion and Brownian Motion (Ex 2 & 8: spread and passage times)
- Google PageRank (Ex 6: a real steady-state = long-run fractions)