Markov Chain Steady State Calculator
Find the steady-state distribution of a Markov chain by solving pi P = pi, with the residual printed and a reducible chain refused.
Markov Chain Steady State Calculator
Find the steady-state distribution of a Markov chain by solving pi P = pi, with the residual printed and a reducible chain refused.
How this page computes
The matrix is validated: square, non-negative, and every row summing to 1 within 1e-9. The system pi (P − I) = 0 is assembled with the last equation replaced by the normalisation.
Gauss–Jordan elimination with partial pivoting solves it, and the residual |pi P − pi| is computed from the original matrix, not from the eliminated one, so a solver mistake would show.
The calculation runs entirely in this browser tab; nothing is uploaded.
A Markov chain forgets where it started, and the page finds the distribution it settles into. For the two-state chain with rows 0.9 0.1 and 0.2 0.8 the steady state is two thirds and one third, because 0.9 times 2/3 plus 0.2 times 1/3 returns 2/3.
The answer is a solution of pi P = pi with the entries summing to one, solved exactly by elimination rather than by running the chain for a million steps. A chain with two closed classes has no single steady state, and the page refuses instead of printing whichever starting point happened to be used.
How to use Markov Chain Steady State Calculator
Write the matrix one row per line, with each row's entries separated by spaces. Every row must sum to 1, because each row is a set of probabilities.
Press Run for the steady-state vector. The largest value of |pi P − pi| is printed as the residual, which is how the answer is checked against its own definition.
Solving pi P = pi exactly, and when it has no answer
The equations pi P = pi are rearranged to pi (P − I) = 0, and the last of them is replaced by the normalisation sum(pi) = 1. Gauss–Jordan elimination with partial pivoting then solves the n by n system, so the cost is cubic in the number of states rather than dependent on how long you run the chain.
If a pivot vanishes at the 1e-12 tolerance the system is singular, which happens exactly when two or more closed classes never communicate. Then the long-run distribution depends on where the chain started, so "the" steady state does not exist and the page says so.
What to Expect
Best for
- The long-run share of time spent in each state
- Checking a two- or three-state chain by hand
- Seeing why a reducible chain has no single answer
Not ideal for
- Transient behaviour after a specific number of steps
- Rows that do not sum to 1, which the page refuses
- A chain with several closed classes, which has infinitely many stationary distributions
What this tool keeps
- Every probability exactly as typed, to within 1e-9 on each row sum
What may need cleanup
- Nothing: the vector is a solution of the defining equations
Common errors
- A row that does not sum to 1 is refused with the sum printed
- A negative entry is refused
- A non-square matrix is refused with the row width
Example use cases
- Find the long-run split of a two-state weather model
- Check that a symmetric chain has a uniform steady state
- See a reducible chain refused with the reason
Sample input
0.9 0.1 and 0.2 0.8
Sample output
steady state [0.66666667, 0.33333333] with residual 0
Who this is for
- Students meeting Markov chains
- Readers checking a page-rank style model
Frequently asked questions
What does the residual mean?
It is the largest absolute difference between pi P and pi. Zero means the printed vector exactly satisfies the defining equation; the page prints it so the claim is checkable rather than asserted.
Why does my chain have no steady state?
Most often because two closed classes never communicate, so the long-run share depends on the start. The page detects the singular system and names that reason instead of printing one of the infinitely many stationary distributions.
Can the rows be given as counts instead of probabilities?
No. A row must sum to 1, because it is a distribution over the next state. Convert counts to fractions first, and the row-sum check will confirm the conversion.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.