Source: https://goodhandover.co.uk/tools/markov-chain-calculator/

[Computer science maths](https://goodhandover.co.uk/tools/computer-science-maths/#year-3) / Year 3

🔒 Files never leave your device

# Markov chain calculator

Advance an initial distribution through a finite Markov chain. Your inputs stay on your device.

## Set up your task

Ready. Processing stays in this browser.

Files and text stay on your device. [Privacy details](https://goodhandover.co.uk/privacy/).

 

## How to use Markov chain calculator

Advance an initial distribution through a finite Markov chain. The pre-filled problem gives you a worked starting point. Compare the response with your own working before trying the self-check below.

 

- Check the example inputs: Transition matrix (one row per line), Initial probabilities, Number of steps.

- Change the inputs for your problem. Results update as you type, so finish entering the values before copying an answer.

- Use the working to check an intermediate value or assumption. Then change the example as suggested in the self-check and compare the result.

 

## Supported inputs and limits

Use a square matrix of up to eight states. Each row and the initial distribution must contain probabilities that sum to one.

 

## How it works

A Markov chain describes a random process whose next-state probabilities depend on the current state. A row of the transition matrix gives the distribution of the next state for a fixed current state. All rows therefore sum to one under this convention.

Multiply the current row distribution by the transition matrix to get the next distribution. Each destination probability receives contributions from every possible current state, weighted by the chance of reaching that destination in one step. Iterating shows how an initial concentration of probability can spread through available transitions.

 

## Example

Run the pre-filled example. Its first result is “After 2 steps: 0.72  0.28”.

Transition matrix (one row per line)

0.8 0.2

0.4 0.6

Initial probabilities

1 0

Number of steps

2

After 2 steps: 0.72  0.28
Step 1: 0.8  0.2
Step 2: 0.72  0.28
Multiply the previous row vector by the transition matrix.

 

## Questions about Markov chain calculator

### Can transition rows use fractions such as 1/3?

Use decimal input with enough precision that the rows sum to one within a billionth. Fractions supplied as a slash expression are unsupported here.

### What do zero steps return?

Zero steps leave the supplied initial distribution unchanged. The transition matrix is still checked for a valid state space.

### Set the example step count to one.

The answer is 0.8 and 0.2, the first row of the matrix. The initial distribution puts all its probability in the first state.

 
 

## Related tools

[Year 3: Advanced and applied maths](https://goodhandover.co.uk/tools/computer-science-maths/#year-3)

- [Stationary distribution calculator](https://goodhandover.co.uk/tools/stationary-distribution-calculator/)

- [PageRank calculator](https://goodhandover.co.uk/tools/pagerank-calculator/)

- [Shannon entropy calculator](https://goodhandover.co.uk/tools/shannon-entropy-calculator/)

- [KL divergence calculator](https://goodhandover.co.uk/tools/kl-divergence-calculator/)

 

Last updated 24 November 2026
