Markov Chain Calculator

Steady-state (long-run) probabilities and n-step transition probabilities for a Markov chain with 2 to 4 states, with a regular/absorbing check.

One row per line, 4 states at most. Row i, column j is the chance of moving from state i to state j in one step, so each row adds up to 1. Decimals (0.25) or fractions (1/3).
Separated by commas, in row order. Leave empty for 1, 2, 3, …
The share in each state now, adding up to 1. Enter 1 0 0 to start in the first state. Leave empty to see only the n-step matrix.
A whole number from 0 to 1,000,000.

Results

Steady-state (long-run) distribution π
A: 0.125 (12.5%) B: 0.3 (30%) C: 0.575 (57.5%)
Solves πP = π with the entries adding up to 1.
Distribution after 2 steps (V₀·Pⁿ)
A: 0.132 (13.2%) B: 0.3865 (38.65%) C: 0.4815 (48.15%)
2-step transition matrix Pⁿ (row = from, column = to)
A B C A 0.16 0.47 0.37 B 0.12 0.44 0.44 C 0.12 0.19 0.69
Type of chain
Regular: some power of the matrix has all positive entries, so from any start the distribution settles to the steady state.

How it’s calculated

A Markov chain moves between a few states, and the chance of the next state depends only on the current one. The transition matrix P holds those chances: row i, column j is the probability of going from state i to state j in one step, so each row adds up to 1.

Distribution after n steps: Vₙ = V₀ · Pⁿ n-step probability from i to j: entry (i, j) of Pⁿ Steady state π: π·P = π and π₁ + π₂ + … = 1

Pⁿ is computed by repeated squaring. The steady state is found by solving the linear equations πP = π directly, not by raising P to a large power. It is unique when the chain has a single closed group of states (one it can never leave). If there are several, for example two absorbing states, the long run depends on the start, and the calculator says so and shows the steady state within each group. A chain is regular when some power of P has no zero entries; then every row of Pⁿ approaches the steady state.

Worked example (Sekhon and Bloom, Applied Finite Mathematics §10.1): a bike share has stations A, B and C. Bikes from A end the day at A, B, C with probabilities 0.3, 0.5, 0.2; from B 0.1, 0.6, 0.3; from C 0.1, 0.1, 0.8. Starting with 30%, 45% and 25% of bikes, after two days the shares are 13.2%, 38.65% and 48.15%, and a bike borrowed from A is at C two days later with probability 0.37 (entry A→C of P²). Solving πP = π gives the long-run shares π = (0.125, 0.3, 0.575): 12.5% of bikes at A, 30% at B and 57.5% at C.

Frequently asked questions

Which way round does the matrix go?

Rows are the current state and columns the next state, so each row adds up to 1. Some books use the transpose (columns adding to 1); if yours does, enter its columns as rows.

What if my rows do not add up to exactly 1?

Rows must total 1 within 0.000001, so 0.333 0.333 0.334 works. For thirds you can type fractions: 1/3 1/3 1/3. Each row is then rescaled to add up to exactly 1.

Why is the steady state “not unique”?

The chain has two or more closed groups of states that it can never leave, such as two absorbing states. Where it ends up depends on where it starts, so there is no single long-run distribution. Use the n-step matrix with a large n to see the long-run outcome from each starting state.

What does periodic mean?

The chain cycles in a fixed rhythm, for example A → B → A → B. Pⁿ then keeps alternating instead of settling, but the steady state still tells you the long-run fraction of time spent in each state.

Embed this calculator

Add this free calculator to your own website. Copy the code below into your page’s HTML:

Need this calculator branded, changed or built around your own prices?See custom business solutions →

Sources

Formulas are taken from the free public references above. Results are provided “as is” for informational and educational purposes only. See our disclaimer.

Added · Last updated · How we check our calculators

Spotted a mistake or missing option? Report a problem· Suggest a calculator