Probability

Markov Chains

A three-state Markov chain with a transition matrix. Run the chain and watch the distribution converge to a stationary state.

5 minLevel 3/3The interactive stage stays ad-free.
Steps0Most likelyATotal probability1.00
A
100.0%
B
0.0%
C
0.0%

Transition matrix

fromABC
A0.60.30.1
B0.20.50.3
C0.10.20.7

The distribution is a row vector. Each step multiplies it by the transition matrix. After many steps it approaches the stationary distribution, where the state probabilities stop changing.

What you are seeing

1

Each state has probabilities for moving to other states; each row of the transition matrix sums to 1.

2

Multiplying the distribution row vector by the transition matrix gives the next distribution.

3

After many steps, the distribution often approaches a fixed point: the stationary distribution.

Why it matters

Markov chains model weather, queues, PageRank, speech recognition, and reinforcement learning.

Complexity & details

One step with s states: O(s²) for a dense transition matrix. Many steps: O(k s²).

Frequently asked questions

What is the Markov property?+

The next state depends only on the current state, not on the full history. The future is independent of the past given the present.

Does every chain have a stationary distribution?+

Finite irreducible and aperiodic chains have a unique stationary distribution. Periodic or reducible chains may not converge from every start.