Study and Productivity

Markov Chains Made Simple: Transition Matrices, Steady States and Absorption

Learn how to build a transition matrix, find probabilities after n steps, solve for the steady state and analyse absorbing Markov chains with examples.

Saizul Amin
Saizul Amin3 Nov 2026 · 4 min read
Markov Chains Made Simple: Transition Matrices, Steady States and Absorption

Markov Chains Made Simple: Transition Matrices, Steady States and Absorption

A Markov chain is a model of something that moves between states in steps, where the chance of the next move depends only on the current state. It is named after Andrey Markov, who studied such chains around 1906. Today they power weather models, customer churn forecasts, board-game analysis and the original PageRank algorithm. This guide explains the core calculations with worked examples you can reproduce in the free Markov chain calculator.

The transition matrix

Suppose tomorrow's weather depends only on today's:

  • after a sunny day: sunny with probability 0.9, rainy 0.1
  • after a rainy day: sunny 0.5, rainy 0.5

Write these as a matrix P, one row per current state:

from \ toSunnyRainy
Sunny0.90.1
Rainy0.50.5

Every row must add up to 1, because from each state something must happen next. The calculator checks the row sums and offers to rescale rows that do not add up. It also draws a state diagram with an arrow for each non-zero probability.

Probabilities after n steps

Write the current distribution as a row vector. If today is sunny, π₀ = (1, 0). Then:

  • π₁ = π₀P = (0.9, 0.1)
  • π₂ = π₁P = (0.9 × 0.9 + 0.1 × 0.5, 0.9 × 0.1 + 0.1 × 0.5) = (0.86, 0.14)

In general πₙ = π₀Pⁿ. The entry in row i, column j of Pⁿ is the probability of being in state j after n steps, starting from state i. The calculator lists the first few steps, plots each state's probability over time and shows Pⁿ for any n up to 500.

The steady state

Run the weather chain long enough and the starting day stops mattering. The distribution settles at a steady state π that satisfies

πP = π, with the entries adding to 1.

For the weather chain, write π = (s, r):

  • s = 0.9s + 0.5r
  • s + r = 1

The first equation gives 0.1s = 0.5r, so s = 5r. With s + r = 1, r = 1/6 and s = 5/6. In the long run, five days in six are sunny.

One of the πP = π equations is always redundant, which is why it is replaced with the sum condition. The calculator writes the equations out this way and solves them by elimination, so you can match your own working.

When is the steady state reached?

A chain is regular if some power of P has all positive entries. Regular chains converge to their steady state from any start. A chain that strictly alternates between two states is irreducible but has period 2, so πₙ keeps flipping; its steady state still gives the long-run fraction of time in each state. The calculator reports whether your chain is irreducible, its period and whether it is regular.

Absorbing chains

A state is absorbing if, once entered, it is never left: P(i, i) = 1. Think of graduating, going bankrupt or finishing a board game.

Gambler's ruin. A player has $2 and bets $1 on fair coin tosses, stopping at $0 or $4. States $0 and $4 are absorbing. Questions: how long does the game last on average, and what is the chance of reaching $4?

The method:

  1. Separate the transient states from the absorbing ones.
  2. Q holds transient-to-transient probabilities, R transient-to-absorbing.
  3. Compute the fundamental matrix N = (I − Q)⁻¹. Entry N(i, j) is the expected number of visits to transient state j starting from i.
  4. Expected steps before absorption: add up each row of N.
  5. Absorption probabilities: B = NR.

For the gambler starting with $2, the expected length is 4 tosses and the chance of reaching $4 is 1/2. Starting with $1, the game lasts 3 tosses on average and the chance of reaching $4 is only 1/4.

The calculator's "Student progress" example applies the same idea to a two-year course: a first-year student graduates with probability 5/6 and takes about 2.16 years on average to either graduate or leave.

Simulation

Formulas give averages, but individual runs vary. The Simulate tab takes 40 random steps through your chain and shows the share of time spent in each state next to the steady state. Run it several times to see how much a single path wanders.

Tips for exam questions

  • Check row sums before anything else.
  • Use the row-vector convention πP consistently; mixing it with column vectors is the most common source of errors.
  • For steady states of 2-state chains, a shortcut is π(A) = P(B→A) ÷ (P(A→B) + P(B→A)).

Limits

The calculator handles discrete-time chains with up to eight states and constant transition probabilities. It does not cover continuous-time chains or hidden Markov models, and a Markov model is only as good as its assumptions about the real situation.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages