Explainer
Transition Matrices At A Glance
The compact table that predicts long-term wandering states.
A Markov chain is a system that hops between a set of states. The rule for hopping is simple: where you go next depends only on where you are now. Not on how you got there. The whole thing fits in one grid of numbers called a transition matrix.
Each row is a state you could be in right now. Each column is where you could go next. The number at the crossing is the probability of that hop in one step. Every row adds to 1, because you have to go somewhere. Read across one row and you have the full set of options from that spot.
Table
Weather, one step ahead
| From ↓ / To → | Sunny | Rainy |
|---|---|---|
| Sunny | 0.9 | 0.1 |
| Rainy | 0.5 | 0.5 |
A sunny day stays sunny nine times in ten. A rainy day stays rainy only half the time. Those two rows are the entire model. Nothing about last week enters the calculation, which is exactly the property that makes this a Markov chain.
Formula
Distribution after n steps
Variables
- the starting odds, a row of probabilities
- the transition matrix
- the odds after n steps
Definition
If you know today's odds across the states as a row vector, multiplying by the matrix again gives tomorrow's odds. Repeat n times and you have n steps ahead.
Example
Start certain it is sunny, = (1, 0). One step later you have (0.9, 0.1).
See also
Keep multiplying and something settles. For this weather grid the odds drift toward about 83% sunny and 17% rainy, no matter where you began. That settled mix is the stationary distribution. It is the answer to 'what fraction of time do we spend in each state, eventually?'
Tip
Check your rows first
Before you trust any result, add up each row. If a row does not sum to 1, the grid is describing something that cannot happen, and every number downstream is wrong. This single check catches most broken models.
Examples
- Rows of 0.9 and 0.1 are valid.
- Rows of 0.9 and 0.3 are not, and the error will not announce itself.
Choose
