Lesson
The theory — Markov Chain Stationary Explorer
A distribution is stationary when one more step changes nothing: πP = π. It is a fixed point of the transition matrix — the chain still moves between states, but the proportions stop shifting.
What each symbol means
P- the transition matrix. Entry in row i, column j is the probability of moving from state i to state j, so every row must sum to 1 — which the grid above checks for you.
p(0)- the initial distribution: where the chain starts. The default
(1, 0, 0)means it begins in state 1 with certainty. p(k)- the distribution after k steps, obtained by multiplying by
Ponce per step. π- the stationary distribution — the one that satisfies
πP = π. k- how many steps to take, set above. The trajectory table shows every distribution from
p(0)top(k).
Where the formula comes from
- Write what stationarity demands: after one step the distribution is unchanged, so
πP = π. - Rearranged, that is
π(P − I) = 0— a system of linear equations, one per state. On its own it has infinitely many solutions, because any multiple of a solution is also one. - Add the condition that makes it a probability distribution,
Σπ = 1, and the answer is pinned down. For the default matrix it is exactly8/13, 3/13, 2/13— the0.615385, 0.230769, 0.153846reported above.
How to read what you see
Three panels. p(k) is where the chain actually is after your k steps; π is where it is heading, with the iteration count and whether it converged; and distance to stationarity measures the gap between them — 0.08893 at the default k = 8, which is why the note says the chain has not fully mixed yet. The trajectory table below shows every step, starting from (1, 0, 0).
- Assumes
- A finite set of states and probabilities that never change with time. Each row summing to 1 is not a formatting rule but the statement that the chain must go somewhere on every step.
- Breaks when
- The
πabove is labelled an estimate for a reason: it is reached by stepping the chain repeatedly — 83 iterations for the default matrix — and stopped when successive distributions stop moving. That is a numerical judgement, not a proof. The exact answer here is the set of rationals8/13, 3/13, 2/13, and the printed decimals are those rounded to six places.
Practice
Check yourself
Predict the answer first, then use the controls above to find out. Reveal only after you have committed to a guess — that is what makes it practice.
-
The default starts the chain in state 1 with certainty,
p(0) = (1, 0, 0). Change it to(0, 0, 1)so it starts in state 3 instead. Predict which readouts move and which do not.Show answer
p(k)and the distance move;πand the iteration count do not. From state 1, eight steps reach0.659852, 0.218714, 0.121436, a distance of0.08893. From state 3 they reach0.522304, 0.255274, 0.222421, a distance of0.18616— further out, because state 3 is the rarest destination. Both timesπreads0.615385, 0.230769, 0.153846after the same83iterations. Where the chain starts decides how far along it is, never where it is heading:πP = πmentions the matrix and nothing else. -
Back to
(1, 0, 0), and now raise the step count. How many steps before the distance to stationarity reads0— and has the chain then arrived?Show answer
k = 80prints0, and no, it has not. Atk = 40the distance is already0.000024; the six decimals the panel prints simply run out before the gap does. This chain approachesπgeometrically and never reaches it in finitely many steps, so the0is the display rounding — the same reasonπitself is labelled an estimate. Comparek = 8, where the distance is0.08893and the note still says the chain has not mixed.
Problem solved in full
-
Eight steps of a three-state chain started in state 1 5 steps
A three-state chain started entirely in state 1, run for eight steps. Work out where it is heading, and how far it still has to go.
-
One step is a vector-matrix product: the chance of being in state j next is the sum over i of being in i now and moving i → j.
-
Eight steps of that gives the distribution the panel prints. State 1 still holds two thirds of the probability, which is a lot given the chain started there with certainty.
-
The destination is the stationary distribution — the one that a step leaves unchanged. Solving πP = π with the probabilities summing to 1 gives exact fractions, eighths and thirteenths, not decimals.
-
Comparing the two gives the distance the panel reports, and it is not small: after eight steps the chain is still about 0.089 away in total.
-
That gap shrinks geometrically, governed by the second-largest eigenvalue of P. Geometric decay means it halves in a fixed number of steps and never reaches zero in finitely many.
Answer
The tool prints 0.65985, 0.218714, 0.121436 after eight steps, still 0.08893 from stationarity. The stationary distribution is exactly (8/13, 3/13, 2/13), and the fact worth keeping is that it does not depend on where you started: those same three fractions are the limit from every starting distribution, which is what makes them a property of the transition matrix rather than of this particular run. That independence is what makes stationary distributions useful: PageRank, MCMC sampling and queue occupancy all rely on the long-run answer being a property of the transition rules alone. Only the time taken to get there depends on the start.
-
References (1)
- The stationary distribution put to work on the whole web, damping factor and all: S. Brin & L. Page, “The anatomy of a large-scale hypertextual Web search engine.” Computer Networks and ISDN Systems 30, 107–117, 1998.