4.10.27 · D4Advanced Topics (Elite Level)

Exercises — Stochastic processes — Markov chains, steady-state, random walks

2,705 words12 min readBack to topic

Throughout, remember the three chants from the parent: "Row times P, In equals There, Spread is √n."


Level 1 — Recognition

Goal: read the objects. No heavy computation — just "what is this thing and does it obey the rules?"


Exercise 1.1. Is the following a valid transition matrix of a Markov chain?

State the single rule you must check, and check it.

Recall Solution 1.1

What rule? A transition matrix must be row-stochastic: every row is a list of probabilities of going somewhere, so each row must sum to (parent note, §1). Entries must also be .

Check row by row:

  • Row 1 (from state 1):
  • Row 2 (from state 2):
  • All entries

Answer: Yes, it is a valid transition matrix.


Exercise 1.2. A chain has current distribution — meaning a chance of being in state 1 and in state 2. Using from Exercise 1.1, which product gives the distribution one step later: or ? Then compute it.

Recall Solution 1.2

Which product? The update rule is — a row vector times the matrix (parent, §1, "Row times P"). We sum over the current state , which is the row index of , and that summation is exactly a row-vector–matrix product. So the correct product is .

Compute (row vector rule: new -th entry ): Answer: . (Sanity: it sums to . Good — probability is conserved.)



Level 2 — Application

Goal: turn the crank. Solve the defining equations correctly.


Exercise 2.1. Find the stationary distribution of

Recall Solution 2.1

What we want: the row vector that is unchanged by one step, i.e. with (parent, §2). "In equals There."

Write out component by component:

Use the first equation (the two are always redundant for a chain; that's why we also need normalisation):

Normalise with :

Answer: .


Exercise 2.2. For the weather chain from the parent note,

compute the distribution after two days, .

Recall Solution 2.2

Plan: apply "Row times P" twice: , then . (Equivalently .)

Day 1: So .

Day 2:

Answer: . Notice it is already creeping toward the stationary from the parent note — convergence in action.



Level 3 — Analysis

Goal: see the structure — why an answer must take the form it does.


Exercise 3.1. A symmetric random walk () starts at and takes steps of size . Without simulating, give (a) the expected position , (b) the variance , and (c) the typical distance from the origin. Explain why the mean and the typical distance disagree.

Recall Solution 3.1

Let each step be and (parent, §3).

(a) Mean. . Sums of means: .

(b) Variance. , so . Steps are independent, and variances of independent things add: .

(c) Typical distance standard deviation .

Why they disagree: The mean is a signed average — leftward and rightward wanderings cancel, giving . But the spread doesn't care about sign; each step contributes to the variance whether it went left or right. So the cloud of possible positions gets wider like , even though its center stays glued to . See figure — the center (amber line) is flat while the envelope (cyan) fans out.

Figure — Stochastic processes — Markov chains, steady-state, random walks

Exercise 3.2. In the fair gambler's ruin on , the first-step analysis gives Show from this equation alone that must be a straight line in , and hence .

Recall Solution 3.2

Rearrange the recurrence to expose the shape:

Read this out loud: the gap between consecutive values, , satisfies . So every gap is the same constant . A sequence with constant steps is an arithmetic progression — i.e. a straight line: .

Pin the constant using the other boundary :

The geometry: constant gaps = a ramp from to . See the straight amber line below.

Figure — Stochastic processes — Markov chains, steady-state, random walks


Level 4 — Synthesis

Goal: combine tools — chain structure + eigenvalues + conditions for convergence.


Exercise 4.1. Consider the periodic 2-state chain

(a) Find its stationary distribution. (b) Show that starting from the distribution never converges to it. (c) Which convergence condition from the parent note fails, and why?

Recall Solution 4.1

(a) Stationary , , solve : Set . With : . A stationary distribution exists.

(b) Iterate from : It oscillates forever, never approaching . So .

(c) Which condition fails? Aperiodicity. This chain has period 2: from state 1 you can only return to state 1 after an even number of steps (). The forced cycle length is , so the chain is periodic. Irreducibility holds (each state reaches the other), but the Perron–Frobenius convergence guarantee (Perron–Frobenius Theorem) needs both irreducible and aperiodic. Missing aperiodicity ⇒ a that exists but is never reached.

(Eigenvalue view: has eigenvalues and . The eigenvalue has magnitude , so its contribution never decays — it flips sign each step, producing the eternal oscillation. Aperiodicity is exactly the condition that is the only eigenvalue of magnitude . See Linear Algebra — Eigenvalues and Eigenvectors.)


Exercise 4.2. A frog hops on 3 lily pads with

(a) Verify it is row-stochastic. (b) Find its stationary distribution using the balance equations + normalisation. (c) Is it aperiodic?

Recall Solution 4.2

(a) Row sums: each row has a single and two s → sum . ✔ Row-stochastic.

(b) Stationary , solve . Compute (row vector rule, column by column):

  • Column 1 of is : .
  • Column 2 is : .
  • Column 3 is : .

So . Setting : Normalise . By symmetry the frog spends equal time on each pad.

(c) Aperiodic? No. The frog is forced ; it returns to any pad only after multiples of steps. The period is 3 > 1 ⇒ periodic. So exists and is unique (chain is irreducible), but cycles rather than converges.



Level 5 — Mastery

Goal: invent the method — set up a first-step analysis from scratch and connect to the wider map.


Exercise 5.1 (expected hitting time). For the fair random walk on with absorbing ends, let be the expected number of steps until absorption (hitting or ), starting from . (a) Derive the recurrence for by first-step analysis. (b) Solve it. (c) Evaluate the expected duration of a fair game starting at \3$0$10$.

Recall Solution 5.1

(a) Set up first-step analysis. From position (interior, ) you take one step (that's why a appears), then land at or each with probability , and by the Markov property the process restarts from wherever you land. Conditioning on that first step (law of total expectation, cousin of Law of Total Probability): (The = the step you just spent; the boundaries are because once absorbed, no more steps are needed.)

(b) Solve. Rearrange: So the gaps decrease by 2 each step: — an arithmetic progression. Summing gaps from to : This is a quadratic in ; try the ansatz (a downward parabola vanishing sensibly). Impose : Then . Check ✔, ✔, and it satisfies the recurrence: ✔.

(c) With : steps expected. A fair $3-vs-$10 game lasts, on average, 21 rounds — surprisingly long, because the walk lingers before either barrier catches it.

Compare with the absorption probability from the parent note: a linear answer for "which end," but a quadratic answer for "how long." Same first-step trick, different inhomogeneous term (the ).


Exercise 5.2 (conceptual synthesis). Explain, in the language of this chapter, why Google's Google PageRank is "the stationary distribution of a random walk on the web," and name the single technical ingredient Google adds to guarantee that this stationary distribution is unique and reached.

Recall Solution 5.2

The web as a Markov chain. Model each web page as a state. A "random surfer" at a page clicks one of its outgoing links uniformly at random — that defines a row-stochastic transition matrix (each row = "where a click from this page can go"). The surfer is memoryless: the next click depends only on the current page. So the surfer is a random walk on a giant graph.

PageRank = stationary distribution. The importance of a page = the long-run fraction of time the random surfer spends on it = the entry of the stationary vector solving (left eigenvector for eigenvalue , parent §2). "In equals There": a page is important if lots of importance flows into it.

The ingredient Google adds — teleportation (damping). Raw web-link can be reducible (dead-end pages, disconnected clusters) and periodic, so by Exercises 4.1–4.2 a unique, reachable is not guaranteed. Google mixes in a small probability (about ) of jumping to a uniformly random page instead of following a link: Now every page reaches every other in one step (irreducible) and there are no forced cycles (aperiodic). By the Perron–Frobenius Theorem, has a unique stationary with the power iteration converging to it from any start — exactly the guarantee Exercises 4.1–4.2 showed was missing without it.



Connections

  • Linear Algebra — Eigenvalues and Eigenvectors — every steady-state is a left eigenvector for eigenvalue ; the story explains oscillation (Ex. 4.1).
  • Perron–Frobenius Theorem — the uniqueness & convergence guarantee tested in L4 and used in L5.
  • Law of Total Probability — the conditioning behind every first-step analysis (Ex. 3.2, 5.1).
  • Central Limit Theorem — why the random-walk spread becomes a Gaussian bell (Ex. 3.1).
  • Diffusion and Brownian Motion — the continuum limit of these walks.
  • Google PageRank — the flagship application (Ex. 5.2).