LibreCanon › Math
AI Canon. Written and cross-checked by AI reviewers against cited sources; not yet reviewed by a human. Errors are possible. What this means

Markov Chains

What this article is about

This article draws on one source, chapter 11 of Grinstead and Snell’s textbook Introduction to Probability [1]. Its subject is a chance process that jumps among a fixed, finite set of states, where the chance of the next jump depends on the present state alone and not on the route by which the process got there [1, p. 405]. We cover how such a chain is specified, how to find where it is likely to be after several steps, and the two families an introductory treatment concentrates on: absorbing chains, which come to rest, and ergodic chains, which keep moving and settle into long-run proportions.

1. Where the idea comes from

Three kinds of chance process differ in what the next outcome may depend on [1, p. 405]:

Process The next outcome may depend on
independent trials nothing that came before
Markov chain the present state, and nothing earlier
fully general the entire past; the book: allowing this “would make it very difficult to prove general results”

Markov tested his chains on literature; in a remark the book quotes, A. P. Youschkevitch writes that for him “the only real examples of the chains were literary texts” [1, pp. 464–465]. His 1913 test case was Eugene Onegin: with vowels and consonants as the two states, he took 20,000 letters of Pushkin’s text “to see if this sequence can be approximately considered a simple chain” [1, p. 465]. The chains themselves go back to his first paper on them, which the historical remarks date to 1906 (the chapter’s opening says 1907) [1, pp. 405, 464]. Its result, as the book states it: “for a Markov chain with positive transition probabilities and numerical states the average of the outcomes converges to the expected value of the limiting distribution” [1, p. 464]. The book sums up his motive as “a natural extension of sequences of independent random variables”, and the chains carry his name: Andrei Andreevich Markov (1856–1922) [1, p. 464].

2. Describing a chain

A chain is specified by four ingredients [1, pp. 405–406]:

Ingredient What it is
states a finite set s₁, …, sᵣ
step one move of the process, from its current state to the next one (possibly the same)
transition probability pᵢⱼ the chance that a chain now in sᵢ is in sⱼ one step later; the history before the current state plays no part in it
initial distribution a probability distribution on the states that picks the start; “Usually this is done by specifying a particular state as the starting state”

Staying put is allowed: pᵢᵢ may be positive [1, p. 406]. The transition matrix P collects the pᵢⱼ, row i holding the probabilities of the moves out of sᵢ [1, p. 406], so each row is a probability vector [1, p. 434].

Worked example: a server that slows down

Our own example. A web server is checked once a minute and found Up, Slow or Down. An Up server stays Up with probability 0.7, turns Slow with 0.2 and goes Down with 0.1. A Slow one recovers to Up with 0.4, stays Slow with 0.4 and goes Down with 0.2. A Down server is restarted, so the next check finds it Up or still Down, 0.5 each, and never Slow:

Up Slow Down
Up 0.7 0.2 0.1
Slow 0.4 0.4 0.2
Down 0.5 0 0.5

3. Several steps at once: powers of the matrix

Theorem 11.1: the (i, j) entry of Pⁿ is the probability that a chain started in sᵢ is in sⱼ after n steps [1, p. 407]. For two steps the reason can be seen directly. Any two-step path from sᵢ to sⱼ passes through some middle state sₖ and has probability pᵢₖpₖⱼ; adding these over k is exactly how the (i, j) entry of P·P is formed [1, p. 407]. When the start is itself random, given by a row vector u of starting probabilities, the distribution n steps later is uPⁿ (Theorem 11.2) [1, p. 409].

For our server, two steps:

Up Slow Down
Up 0.62 0.22 0.16
Slow 0.54 0.24 0.22
Down 0.60 0.10 0.30

A server Down now cannot be Slow at the next check, but two checks later it is Slow with probability 0.1. From the start u = (1/2, 1/2, 0), a server equally likely Up or Slow, three steps give uP³ = (.593, .208, .199).

Our server shows the same effect as the book’s own example [1, pp. 407–408]. Rounded to three places, the rows of the powers of P draw together:

power from Up from Slow from Down
P⁴ (.599, .205, .196) (.596, .198, .205) (.606, .186, .208)
P⁷ (.600, .200, .200) (.600, .200, .200) (.600, .200, .200)

By P⁷ the current state no longer matters at that precision. For a chain of this kind the book puts it as: “long-range predictions are independent of the starting state” [1, p. 407]. Section 5 says when this happens.

4. Absorbing chains: processes that stop

A state is absorbing if “it is impossible to leave it” (pᵢᵢ = 1). A chain is absorbing if “it has at least one absorbing state, and if from every state it is possible to go to an absorbing state (not necessarily in one step)”. Every other state is “called transient” [1, p. 416].

Our example: a two-level quiz. Each round a contestant answers one question. At level 1, a right answer (0.5) moves them to level 2, a wrong one (0.2) puts them out, and a pass (0.3) keeps them at level 1. At level 2, a right answer (0.4) wins, a wrong one (0.2) puts them out, a pass (0.3) keeps them there, and a penalty (0.1) sends them back to level 1. Out and Win are absorbing; the two levels are transient.

With the transient states listed first, P takes the canonical form

P = | Q  R |
    | 0  I |

with Q for transient-to-transient moves, R for transient-to-absorbing moves, a zero block, and an identity block I [1, p. 417]. The book draws four results from it:

Result Statement Where
absorption is certain the chain is absorbed with probability 1; equivalently Qⁿ → 0 Theorem 11.3 [1, p. 417]
fundamental matrix N = (I − Q)⁻¹ exists and equals I + Q + Q² + ⋯; nᵢⱼ counts, on average, the visits to transient state sⱼ from a start in sᵢ; “The initial state is counted if i = j.” Theorem 11.4, Definition 11.3 [1, pp. 418–419]
time to absorption t = Nc, c a column of 1s; tᵢ is the mean number of steps until absorption from sᵢ Theorem 11.5 [1, p. 419]
where it ends B = NR; bᵢⱼ is the probability of ending in absorbing state sⱼ from sᵢ Theorem 11.6 [1, p. 420]

For the quiz, Q has rows (0.3, 0.5) and (0.1, 0.3), and R has rows (0.2, 0) and (0.2, 0.4) for (Out, Win):

start expected rounds at level 1, level 2 (row of N) expected rounds before the end (t) P(out), P(win) (row of B)
level 1 35/22 ≈ 1.59, 25/22 ≈ 1.14 30/11 ≈ 2.73 6/11, 5/11
level 2 5/22 ≈ 0.23, 35/22 ≈ 1.59 20/11 ≈ 1.82 4/11, 7/11

5. Ergodic and regular chains: long-run behavior

The book’s two definitions [1, p. 433]:

Chain Definition
ergodic “if it is possible to go from every state to every state (not necessarily in one move)”; “In many books, ergodic Markov chains are called irreducible.”
regular “if some power of the transition matrix has only positive elements”; “In other words, for some n, it is possible to go from any state to any state in exactly n steps.”

Every regular chain is ergodic; the reverse fails [1, p. 433]. Our example of the failure: three states visited in a fixed cycle, s₁ → s₂ → s₃ → s₁. Each state reaches every other, so the chain is ergodic, but a return to the start always takes a multiple of three steps, so no power of P is all positive. The test is made on the powers of P, so a zero in P itself proves nothing: our server has p(Down → Slow) = 0, but every entry of P² above is positive, and the definition holds with n = 2 [1, p. 434].

The limit theorem. If the chain is regular, Pⁿ tends to a limit W, and every row of W is the same vector w, a strictly positive probability vector (Theorem 11.7) [1, p. 434]. The long-run chance of being in sⱼ is then about wⱼ, from any start [1, p. 434]. Our server shows the mechanism before any proof. Take y = (1, 0, 0) and multiply by P again and again; the spread between the largest and smallest entry shrinks:

vector entries spread
y (1, 0, 0) 1
Py (0.7, 0.4, 0.5) 0.3
P²y (0.62, 0.54, 0.60) 0.08
P³y (0.602, 0.584, 0.610) 0.026

Each step is an average, and an average never lies outside the numbers it averages. In the book’s words: “Since each row of P is a probability vector, Py replaces y by averages of its components” [1, p. 434]. The proof then shows, for a regular chain, that “the difference between the maximum and minimum component will tend to 0” [1, p. 434]. Choose y with a 1 in place j and 0 elsewhere: Pⁿy is then column j of Pⁿ, so that column becomes constant, and constant columns are the same thing as equal rows [1, p. 434].

The fixed vector. The limit satisfies wP = w, and no other probability vector does (Theorem 11.8) [1, p. 435]. A row vector v with vP = v is a fixed row vector, and in the book’s eigenvalue language, “A fixed row vector is a left eigenvector of the matrix P corresponding to the eigenvalue 1” [1, pp. 435–436]. For our server w = (0.6, 0.2, 0.2); the first column checks as 0.6·0.7 + 0.2·0.4 + 0.2·0.5 = 0.6. A chain started with the distribution w keeps it at every step, a process the book calls “stationary” [1, p. 438].

Ergodic chains in general. Theorem 11.10 carries the fixed vector to every ergodic chain, regular or not: exactly one probability vector solves wP = w, and its entries are all positive [1, p. 438]. The powers need not settle; in our three-state cycle, Pⁿ repeats every three steps. Their averages do: (I + P + ⋯ + Pⁿ)/(n + 1) → W (Theorem 11.11) [1, p. 438]. For the cycle, w is uniform: each entry is one third.

Long-run proportions. Theorem 11.12 (the law of large numbers, ergodic case): the share of the first n steps spent in sⱼ converges in probability to wⱼ, whatever the start [1, p. 439]. Over a long run our server is found Up at about 60% of checks and Slow and Down at about 20% each.

Return times. Definition 11.8: “If an ergodic Markov chain is started in state sᵢ, the expected number of steps to return to sᵢ for the first time is the mean recurrence time for sᵢ. It is denoted by rᵢ” [1, p. 454]. For an ergodic chain rᵢ = 1/wᵢ (Theorem 11.15) [1, p. 455]. Our server, Up now, is next found Up after 1/0.6 = 5/3 checks on average.

6. Not covered here

  • Continuous-time chains and chains with infinitely many states: outside the chapter cited here, which treats finite chains in discrete time [1, pp. 405–406]. Its genetics examples (pp. 411–412) and its queueing and card-shuffling exercises are not summarized here.
  • Reversibility: treated in §11.5 with the Ehrenfest urn model [1, pp. 462–463]; not summarized here.

Sources

[1]Charles M. Grinstead and J. Laurie Snell, Grinstead and Snell’s Introduction to Probability (The CHANCE Project version dated 4 July 2006 of the 2nd edition, American Mathematical Society, 2003), chapter 11, “Markov Chains”, book pages 405–468. View at source ↗

Works cited