Transition matrix
Each row is the probability of moving from that state to every next state.
Use this Markov Chain Builder to enter values, adjust options, and review results in a compact responsive workspace.
Results are calculated automatically as you enter data.
Each row is the probability of moving from that state to every next state.
Drag nodes to arrange the chain. Thicker arrows indicate larger transition probabilities.
▼ See explanations and tips below ▼
A finite Markov chain is a model for a system that moves among a limited number of possible states. The next state is uncertain, but the probabilities of the next state depend only on the current state, not on the full path used to get there. This idea is called the Markov property.
For example, a simple weather model might use the states Sunny, Cloudy, and Rainy. If today is Sunny, the model may assign one set of probabilities for tomorrow. If today is Rainy, it may assign a different set. The model does not ask whether it was Sunny two days ago unless that information is built into the current state.
A finite discrete-time Markov chain is especially useful when a process changes in steps: one day to the next, one customer action to the next, one class period to the next, or one round of a game to the next. The result is not a single guaranteed future path. It is a probability distribution that says how likely each state is after a chosen number of transitions.
Markov chains give a structured way to model uncertainty over time. Instead of saying only “anything can happen,” a Markov chain describes which changes are possible and how likely each change is.
They are useful because they separate a problem into three practical questions:
That makes Markov chains helpful in probability, statistics, operations research, computer science, teaching demonstrations, queueing examples, random walks, and many other settings where a system evolves step by step.
A transition matrix contains one row for each current state and one column for each possible next state. In a row-based convention, the entry \(p_{ij}\) means:
Because a row represents all possible next states from one current state, every row must form a probability distribution:
where \(m\) is the number of states.
A state distribution is also a probability distribution. If there are \(m\) states, the initial distribution can be written as a row vector:
To move one step forward, multiply the current distribution by the transition matrix:
For a specific target state \(j\), this means:
Each new probability is built by adding up all the ways the system could arrive at that state: the probability of being in each source state times the probability of moving from that source state to the target state.
After \(n\) steps, the same idea becomes:
A stationary distribution is a distribution that does not change after one transition:
When a chain converges to a steady state, repeated multiplication by \(P\) moves the distribution closer to this stable vector. Some chains converge quickly, some converge slowly, and some do not converge in the simple “settles to one distribution from every starting point” sense.
Suppose a weather model has three states: Sunny, Cloudy, and Rainy. From Sunny, the transition row is:
| From Sunny to... | Sunny | Cloudy | Rainy |
|---|---|---|---|
| Probability | \(0.75\) | \(0.20\) | \(0.05\) |
The row is valid because:
If the system is definitely Sunny now, the one-step distribution is:
So after one step, the model assigns a \(75\%\) chance to Sunny, a \(20\%\) chance to Cloudy, and a \(5\%\) chance to Rainy.
Using the same transition matrix and starting from Sunny with probability \(1\), the two-step distribution is:
Interpreted as percentages, that is about \(63.25\%\) Sunny, \(25.75\%\) Cloudy, and \(11.00\%\) Rainy after two transitions.
After eight steps with the same starting distribution, the distribution is approximately:
The probabilities have moved closer to a long-run pattern. For this example, the stationary distribution is approximately:
Consider a two-state chain that always switches states:
If the system starts in state A, it is in state B after one step, state A after two steps, state B after three steps, and so on. The future distribution oscillates instead of settling from that starting point.
This chain has a stationary distribution:
but the existence of a stationary distribution does not always mean every starting distribution visibly converges to it step by step. This is one reason steady-state results should be interpreted together with the structure of the chain.
The future distribution is the predicted probability of being in each state after the selected number of transitions. A larger percentage means that state is more likely at that step, not that the state is guaranteed.
The row sum checks whether each row of the transition matrix is a valid probability distribution. A row total near \(1\) means the row accounts for all possible next states from that current state.
The simulation distribution shows deterministic probability evolution. It updates the whole distribution by matrix multiplication. It is not a random sample path where one state is chosen at each step.
The stationary distribution satisfies \(\boldsymbol{\pi}P=\boldsymbol{\pi}\). A unique stationary distribution does not by itself guarantee that every step-by-step distribution converges to it; periodic chains can oscillate, and reducible chains can have more than one stationary distribution.
Displayed percentages may not add to exactly \(100\%\) because each value is rounded for readability. Small rounding differences do not usually indicate a mathematical problem.
In a transition diagram, thicker edges represent larger transition probabilities. A hidden or missing tiny edge in the diagram does not necessarily mean the probability is zero; very small probabilities can still be included in the calculation.
Entering percentages instead of probabilities. A probability of \(75\%\) should be entered as \(0.75\), not \(75\).
Reading columns as the current state. In a row-based transition matrix, rows are the “from” states and columns are the “to” states. Reversing that convention changes the model.
Forgetting that every row must sum to \(1\). A transition row represents all possible next states from one current state. If the row sums to less than \(1\), some probability is missing. If it sums to more than \(1\), the row assigns too much probability.
Using an initial distribution that does not sum to \(1\). The initial distribution must also be a complete probability distribution across the states.
Assuming a stationary distribution is always a unique long-run limit. Periodic chains can oscillate, while reducible chains can contain several closed classes and therefore several stationary distributions. This calculator reports those structural cases separately.
Thinking the simulation is random. Matrix multiplication evolves probabilities exactly according to the transition matrix. It does not simulate one random path unless the tool specifically performs random sampling.
Ignoring hidden small edges. A graph display may hide very small transition arrows to stay readable, while the numerical calculation still uses those probabilities.
Use a finite Markov chain when:
Markov chains are especially useful for teaching probability, demonstrating transition matrices, modeling simple switching behavior, comparing scenarios, and exploring how short-term transition rules affect long-term distributions.
A finite discrete-time Markov chain is a simplified model. It assumes that the same transition matrix applies at every step and that the current state contains all information needed to predict the next-step probabilities.
The calculator works with \(2\) to \(6\) states. That is an interface readability limit, not a mathematical limit of Markov chains.
Probabilities must be decimals from \(0\) to \(1\). Each transition row and the initial distribution must sum to \(1\) within the calculator’s tolerance. The row-sum tolerance is \(0.0001\); accepted totals that differ slightly from \(1\) are normalized once before calculation, while larger mismatches must be corrected.
Prediction steps are whole-number transitions. Entered step counts are rounded to the nearest integer and limited to the range from \(0\) to \(100\).
Stationary distributions are computed from the fixed-point equations \(\boldsymbol{\pi}P=\boldsymbol{\pi}\) together with \(\sum_i\pi_i=1\). The calculator also identifies closed communicating classes and their periods instead of treating a slowly changing iterate as proof of convergence.
The calculator diagnoses closed classes, periodicity, and non-unique stationary distributions, but it does not provide specialized absorbing-chain quantities such as expected time to absorption and absorption probabilities. It also does not model continuous-time chains, time-varying transition matrices, rewards, costs, or Monte Carlo sample paths.
Each row represents all possible next states from one current state. Since the system must go somewhere among the listed states, the probabilities in that row need to add to \(1\).
Enter \(0.75\). The calculator uses probabilities as decimals from \(0\) to \(1\), not whole-number percentages.
One prediction step means one application of the transition matrix. If the states are daily weather types, one step might mean one day. If the states are customer statuses after each interaction, one step might mean one interaction.
Not always. For an aperiodic chain with one closed class, the future distribution approaches its unique stationary distribution. Periodic chains can oscillate, and reducible chains can have different stationary mixtures depending on the initial distribution.
No. The simulation shows the full probability distribution changing by matrix multiplication. It does not randomly choose one state at each step.
You can enter an absorbing state by giving it a row with probability \(1\) of staying in itself and \(0\) of moving elsewhere. However, the calculator does not provide specialized absorbing-chain outputs such as expected time to absorption or absorption probabilities.
Books and Open Textbooks
Online Educational Sources