Statistics & probability

Markov chain calculator from a transition matrix

Analyze a finite row-stochastic Markov chain with n-step evolution, exact stationary families and exact absorbing-state probabilities.

Your numbers

One row per current state and column per next state. Use a square matrix up to 6×6. Rows must sum exactly to one; fractions avoid truncated decimals.
One nonnegative probability per state, summing exactly to one.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

A finite homogeneous Markov chain specifies the next-state distribution from the current state through one transition matrix. This page treats probabilities as rows: entry P_ij describes movement from i to j. Finite-step mode evaluates an initial row times P to the requested power. Stationary mode returns exact extreme stationary distributions, and absorption mode returns exact probabilities and mean times when every closed class is an absorbing state.

THE FORMULAμ_n=μ_0Pⁿ; πP=π; for absorbing chains N=(I−Q)⁻¹, B=NR and t=N1.

A worked example

For P=[[1/2,1/2],[1/4,3/4]] and initial row [1,0], three transitions give [0.34375,0.65625]. The unique stationary row is [1/3,2/3], verified by multiplying it by P. These finite-step and stationary answers are close but not identical. A different chain P=[[0,1],[1,0]] also has stationary row [1/2,1/2], yet a state-one start keeps alternating rather than converging to it.

Good to know

Supports exact rational or six-place decimal inputs in square matrices up to 6×6. Every transition row and the initial row must sum exactly to one; no automatic normalization is applied. Finite powers are numerical and bounded at 1,000,000 steps. Stationary/absorption solves use bounded exact fractions. Transition estimation, parameter uncertainty, nonhomogeneous chains and continuous-time generators are not implemented.

Stationarity is an equation, while convergence is a limiting claim

A stationary row remains unchanged by one transition. That does not mean every starting distribution approaches it. A periodic closed class can preserve cycling, and a reducible chain can contain several closed classes. The calculator identifies the communicating classes and the periods of closed classes so that a stationary row is not silently presented as a universal long-run limit.

Each closed irreducible class contributes one extreme stationary distribution. When several exist, every stationary distribution is a convex combination of those rows. Transient states receive zero stationary mass. The output therefore lists the complete set of extreme rows rather than choosing an arbitrary normalized vector from an underdetermined system and falsely calling that choice the unique stationary answer.

Two states exchange probability using the row-specific transition rates121 → 2: 1/22 → 1: 1/41/23/4
The default transition rows are (1/2,1/2) and (1/4,3/4). From initial state one, three transitions give (0.34375,0.65625). The stationary row is (1/3,2/3), not the same finite-step row.

The matrix power calculator evaluates supplied matrix powers. This page additionally checks stochastic structure and solves stationary or absorbing-chain questions.

Absorption requires checking the whole recurrence structure

An absorbing state stays where it is with probability one. Its presence alone does not guarantee eventual absorption from every other state: another closed class could trap trajectories elsewhere. This absorption mode requires every closed class to be a single absorbing state. Once that condition holds, the transient fundamental matrix gives both destination probabilities and expected steps, which are checked against exact probability and hitting-time identities.

An already absorbed start has expected remaining time zero. A transient state can have a large mean absorption time when its escape probability is small, even though eventual absorption is certain. Those means are not deadlines. Keep the row convention consistent when copying a matrix from another source, and use exact fractions such as one third rather than decimals whose rounded row total falls below one.

A three-state absorption example checks both destinations and waiting time

Take P with rows (1,0,0), (1/4,1/2,1/4) and (0,0,1). States one and three are absorbing, while state two is transient. Its probability of leaving on each transition is one half, so its mean time to first absorption is two steps. Conditional on leaving, the two absorbing destinations are equally likely, giving absorption probabilities one half and one half from state two.

The transient block is Q=(1/2), hence N=(1−1/2)⁻¹=(2). Multiplying N by R=(1/4,1/4) gives B=(1/2,1/2), and multiplying N by a column of ones gives expected time two. Starting in either absorbing state already meets the target and therefore has expected time zero. This example distinguishes a destination probability from a waiting time even though both come from the same fundamental matrix.

A few questions, answered

Why does a matrix containing three 0.333333 entries fail?

Its row sums to 0.999999, not exactly one. Enter 1/3 for each entry when exact thirds are intended.

Can an absorbing chain have several stationary distributions?

Yes. Each absorbing state supplies an extreme stationary distribution, and mixtures are stationary too. Their weights depend on the starting distribution for an absorption-limit calculation.

Find your calculator

Start typing to explore the library.