Stochastic Matrix Generator
A stochastic matrix is a table of transition probabilities, and its defining property is that every row sums to exactly one. Building one with decimals will not give you that — floating point does not add up neatly — so these are constructed as integers over a common denominator, where the sum is a matter of arithmetic rather than of tolerance. Occasionally the columns sum to one as well, which makes the matrix doubly stochastic and the uniform distribution stationary.
What this generator does
Splits the denominator into as many non-negative parts as there are states, once per row, by choosing cut points. Each row therefore sums to the denominator exactly, and the decimal view is derived from those integers rather than the other way round.
How to use this tool
- Choose the number of states and the denominator.
- Check that each row sums to one.
- Look for whether the columns happen to as well.
- Copy the matrix to feed a Markov chain simulation.
Understanding the controls
- Matrix size
- Between 2 and 6 states. Each row gives the probabilities of moving from that state to every other.
- Denominator
- Between 10 and 1000. Larger denominators give finer probabilities; a hundred reads as percentages.
- Seed
- Reproduces exactly the same transition matrix.
Common use cases
- Transition matrices for a Markov chain exercise or simulation
- Test data where exact row sums matter
- Showing why probabilities are better stored as fractions
- Illustrating the difference between stochastic and doubly stochastic
- Repeating an identical transition matrix from a seed
How this generator works
Cut points are drawn and sorted, and the gaps between them become the row's entries — a standard way to split a total into parts without bias towards any of them. The check sums each row as integers and requires exactly the denominator, and confirms the decimal view matches the fractions it came from.
Randomness and fairness
The transition probabilities are random; the row sums are exact by construction. Seeded matrices reproduce and are therefore explicitly not cryptographically secure. Unseeded, the browser's cryptographically secure generator draws the cut points.
For how randomness is produced across the whole site, see how Generate Random works.
Limitations and good to know
- Right stochastic only — rows are the outgoing probabilities, which is the usual convention but not the only one.
- Zero entries are possible, so some transitions may be impossible.
- Doubly stochastic matrices appear only by chance and cannot be requested.
- No stationary distribution is computed; the Markov chain simulator does that.
- Transition matrices are not kept; seed one to feed the same chain twice.
Privacy and your data
The matrix is generated in your browser. Nothing about the probabilities or your seed is transmitted.
Related generators
- Markov Chain SimulatorDefine states and transition probabilities, then simulate — with a long-run distribution quoted only when the chain genuinely has one.
- Symmetric Matrix GeneratorMatrices that equal their own transpose, with the trace, determinant and the count of entries that are actually free.
- Random Matrix GeneratorA random 3x3 grid of numbers, for maths practice or placeholder data.
- Positive Definite Matrix GeneratorMatrices built to be positive definite and proved so twice — by Cholesky decomposition and by Sylvester's criterion.