Understanding the Markov chain steady-state calculator — concept and principle
A Markov chain moves between states with fixed probabilities that depend only on the current state. The transition matrix P holds them: row i lists the probabilities of going from state i to each state, so every row sums to 1. The steady state (stationary distribution) π is the long-run share of time spent in each state. It is used for customer retention and brand switching, weather models, machine up/down cycles, queueing and web page ranking. The calculator also shows the distribution after n steps starting from state 1.
How it is calculated
- Steady state: solve πP = π together with π₁ + π₂ + … + πₙ = 1. The calculator rewrites πP = π as (Pᵀ − I)πᵀ = 0, replaces the last equation by the normalization Σπ = 1 (one balance equation is always redundant), and solves the linear system. If that system is singular, there is no unique steady state.
- After n steps: start with (1, 0, …, 0) and multiply by P n times; the result is row 1 of Pⁿ.
The principle
If today's distribution is a row vector x, tomorrow's is xP. A distribution that reproduces itself, πP = π, is a fixed point: once reached, nothing changes. In matrix language π is a left eigenvector of P for eigenvalue 1. For a finite chain that is irreducible (every state can reach every other) and aperiodic, that fixed point is unique and every starting distribution converges to it. The other eigenvalues set the speed: the gap from the steady state shrinks like |λ₂|ⁿ.
Worked example
- Defaults: P = [0.9 0.1; 0.5 0.5], n = 10.
- Balance for state 2: flow in = flow out, 0.1·π₁ = 0.5·π₂, so π₁ = 5π₂.
- With π₁ + π₂ = 1: 6π₂ = 1, giving π = (5/6, 1/6) = (0.833333, 0.166667).
- For a 2-state chain λ₂ = 1 − 0.1 − 0.5 = 0.4, so starting in state 1 the probability of being in state 1 after n steps is 5/6 + (1/6)·0.4ⁿ. Check: n = 1 gives 0.9, n = 2 gives 0.86.
- For n = 10: 0.4¹⁰ ≈ 0.000105, so the result is (0.833351, 0.166649), already very close to π.
How to read the result
πᵢ is the long-run fraction of steps in state i, and 1/πᵢ is the mean number of steps between returns to state i (here 1.2 steps for state 1, 6 for state 2). Compare the n-step distribution with π to see how quickly the chain forgets its starting point.
Common mistakes
- Entering columns instead of rows: in this convention each row must sum to 1.
- Solving Pπ = π (a right eigenvector) instead of πP = π.
- Assuming convergence for periodic chains, such as [0 1; 1 0], which alternates forever even though π = (0.5, 0.5) exists.
Frequently asked questions
What if a row does not sum to 1?
Then P is not a valid transition matrix and the result has no probability meaning. Fix the data first.
When is there no unique steady state?
When the chain splits into separate closed groups, for example the identity matrix, where each state stays put forever.
Sources: John G. Kemeny and J. Laurie Snell, Finite Markov Chains, Springer · Sheldon M. Ross, Introduction to Probability Models, Academic Press — Markov chains