Markov Chain Stationary Distribution Calculator

Enter a matrix, then find long run behavior. Use linear solving or iterative convergence checks. Download tables, share outputs, and verify row sums fast.

Choose size first, then enter the matrix.
Linear solve is exact up to rounding.
Stop when change is below this value.
Higher helps with slow mixing chains.
Each row represents probabilities leaving a state. Every row must sum to exactly 1.

Formula used

For a Markov chain with transition matrix P, the stationary distribution π is a probability row vector that satisfies:

This page computes π in two ways: (1) a linear system built from P, plus a sum constraint, and (2) power iteration πk+1 = πkP until convergence.

How to use this calculator

  1. Set the number of states, then enter a square transition matrix.
  2. Ensure each row sums to one, and values are nonnegative.
  3. Select a computation mode, and set tolerance and iterations.
  4. Press Calculate to show the stationary probabilities above.
  5. Use the download buttons to save CSV or PDF.

Example data table

This example uses three states. It is symmetric around state S2, so the long run probability peaks at S2.

To S1 To S2 To S3
From S1 0.5 0.5 0
From S2 0.25 0.5 0.25
From S3 0 0.5 0.5

Expected stationary distribution for this matrix is approximately: [0.25, 0.50, 0.25].

In-depth guide to stationary distributions

1) What this calculator measures

A finite Markov chain models state-to-state changes using probabilities. The stationary distribution describes the long run fraction of time the system spends in each state, after many transitions. In practical terms, it is the equilibrium probability profile of repeated random updates.

2) Transition matrix data requirements

The input matrix must be row-stochastic: every entry is nonnegative, and each row sums to one. A row represents the probability of leaving a state and landing in each destination state. If a row sum is off, the calculator rejects it to protect physical interpretation.

3) The stationary condition

The stationary vector π satisfies π = πP with Σπi=1. When the chain is irreducible and aperiodic, this solution is unique and represents the limiting distribution. Reducible chains can have multiple stationary solutions, depending on communicating classes.

4) Linear system method

The linear approach rewrites the condition as (PT - I)πT = 0, then replaces one equation with the normalization constraint. This yields a solvable system of n equations. It is fast for small matrices and provides a direct solution up to rounding error.

5) Iterative power method

Power iteration updates a probability row vector using πk+1 = πkP. Starting from a uniform distribution, the sequence often converges to the stationary distribution for well-behaved chains. Slow mixing chains may need higher iteration limits or tighter tolerances.

6) Convergence and residual diagnostics

The calculator reports an L1 residual measuring how close the output is to satisfying π=πP. A small residual indicates numerical consistency. If the iterative residual stays large, the chain may be periodic, nearly decomposable, or the tolerance may be too strict for the chosen iteration cap.

7) Interpreting probabilities as measurable data

Each probability can be read as a long-run occupancy rate. For example, π2=0.50 suggests the system spends about 50% of steps in state S2 in steady operation. Converting to percentages helps compare dominant states and identify bottlenecks or preferred modes.

8) Physics use cases

Stationary Markov models appear across physics: random walks on lattices, hopping transport, discrete diffusion, Monte Carlo sampling, and coarse-grained energy-state transitions. In materials and statistical physics, the stationary distribution approximates equilibrium populations. In networked systems, it summarizes steady traffic through nodes or configurations under probabilistic rules.

FAQs

1) What if my matrix rows do not sum to one?

Each row must represent a valid probability distribution. Use the “Normalize rows” button, then recheck for negative values. If a row sum is zero, revise the row because it cannot be normalized meaningfully.

2) Why do the two methods give slightly different values?

Small differences come from rounding and stopping criteria. The linear solve is direct, while iteration stops when change falls below tolerance. If the chain is reducible or periodic, iteration may not settle cleanly.

3) What does the residual (L1) tell me?

It measures how close the computed vector is to satisfying π=πP. Values near zero indicate a consistent stationary solution. Larger values suggest insufficient iterations, numerical sensitivity, or a chain structure that complicates convergence.

4) How many states can I compute here?

This implementation supports 2 to 10 states for clarity and stability. For larger chains, use specialized numerical libraries or sparse methods, then validate results with a residual check like the one shown here.

5) When is the stationary distribution unique?

Uniqueness is guaranteed when the chain is irreducible and aperiodic. In that case, the long-run distribution does not depend on the starting state. Reducible chains can have multiple stationary distributions.

6) What tolerance should I use for iteration?

Start with 1e-10 for stable chains. If convergence is slow, relax to 1e-8 or increase max iterations. Always compare the final residual: it is a better indicator than iteration count alone.

7) Can I use this for continuous-time processes?

This calculator targets discrete-time chains. For continuous-time Markov processes, first build a discrete transition matrix from a time step, or solve the steady-state of a rate matrix with appropriate normalization.

Related Calculators

Boltzmann factor calculatorPartition function calculatorCanonical ensemble calculatorGrand canonical calculatorMicrocanonical entropy calculatorChemical potential calculatorInternal energy calculatorThermal wavelength calculatorMaxwell Boltzmann speedMean speed calculator

Important Note: All the Calculators listed in this site are for educational purpose only and we do not guarentee the accuracy of results. Please do consult with other sources as well.