Markov Chains
A three-state Markov chain with a transition matrix. Run the chain and watch the distribution converge to a stationary state.
Transition matrix
| from | A | B | C |
|---|---|---|---|
| A | 0.6 | 0.3 | 0.1 |
| B | 0.2 | 0.5 | 0.3 |
| C | 0.1 | 0.2 | 0.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
Each state has probabilities for moving to other states; each row of the transition matrix sums to 1.
Multiplying the distribution row vector by the transition matrix gives the next distribution.
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.