Build and Simulate a Random Walk
Enter a weighted adjacency matrix. Each row represents the current vertex, and each column represents a possible next vertex.
What you can explore
- Weighted adjacency matrices.
- Row-stochastic transition matrices.
- Probability distribution after each step.
- Individual random walk trajectories.
- Empirical vertex visit frequencies.
- Approximate stationary distributions.
- Graph structure and long-term behaviour.
Rows represent current vertices; columns represent destination vertices. A row with no outgoing edges is treated as an absorbing state with a self-loop.
Random Walk Analysis
Long-run behaviour
Network visualization
Vertices represent states. Connections represent possible transitions. Directed edges are shown with arrows.
Adjacency and transition matrices
Initial probability distribution
Probability evolution
The distribution at step k is calculated using \(\boldsymbol{\pi}_k=\boldsymbol{\pi}_0P^k\).
Distribution history
Approximate stationary distribution
The simulator uses Cesàro averages of successive distributions to estimate a stationary probability vector. This method can also produce a stationary estimate for periodic chains.
Random walk simulation
A sample trajectory is generated by randomly selecting the next vertex according to the transition probabilities.
Monte Carlo visit frequencies
Multiple independent walks are used to estimate the proportion of time spent at each vertex. The first visit at time zero is included in each walk.
| Vertex | Visits | Empirical frequency | Stationary estimate |
|---|
Step-by-step mathematical explanation
What Is a Random Walk?
A random walk is a process in which an object moves from one state to another according to specified probabilities. In graph theory, the states are vertices and possible movements are edges.
At every step, the current vertex determines the probability of moving to each possible destination. The next movement is selected randomly according to these probabilities.
A random walk on a finite graph can be represented as a finite-state Markov chain. Its transition matrix contains all one-step movement probabilities.
Adjacency Matrix and Transition Matrix
An adjacency matrix records the connections between vertices. For a weighted graph, the entry \(w_{ij}\) represents the weight of the connection from vertex i to vertex j.
To construct a transition matrix, divide each row by its total outgoing weight:
This produces a row-stochastic matrix: every entry is nonnegative and every row sums to one.
If a vertex has no outgoing edges, the simulator treats it as an absorbing state by assigning a probability of one to remain there.
How a Random Walk Uses Matrix Multiplication
Let the initial probability distribution be a row vector:
The probability distribution after one step is obtained by multiplying the initial distribution by the transition matrix:
After two steps:
More generally, after k steps:
The matrix power \(P^k\) contains the probabilities of moving from each starting vertex to each destination vertex in exactly k steps.
Stationary Distribution of a Random Walk
A stationary distribution is a probability vector that remains unchanged after one transition. It satisfies:
It is therefore a left eigenvector of the transition matrix corresponding to eigenvalue one.
Stationary Distribution and Vertex Degree
For a finite connected undirected weighted graph, the stationary distribution of the ordinary random walk has a particularly simple form.
The weighted degree of vertex i is the sum of the weights of its incident edges:
The stationary probability of vertex i is:
Vertices with more total incident edge weight receive more stationary probability. For an unweighted undirected graph, this reduces to probability proportional to the ordinary vertex degree.
This formula assumes a connected undirected graph with positive degree at every vertex. The simulator uses the general iterative stationary-distribution estimate for directed and disconnected networks.
Where Are Random Walk Matrices Used?
1. Search engines and PageRank
Random-surfer models use transition probabilities between web pages to estimate their relative importance.
2. Network analysis
Random walks help study connectivity, centrality, movement and information flow through networks.
3. Physics and statistical mechanics
Random walks are used to model diffusion, particle movement and stochastic processes.
4. Machine learning
Graph-based learning methods use random walks to explore relationships and generate node representations.
5. Biology and chemistry
Random walks can model movement through molecular networks, biological pathways and interaction graphs.
6. Transportation systems
Transition matrices can describe probabilistic movement between stations, locations and transport connections.
Random Walk Matrix FAQs
1. What is a random walk matrix?
A random walk matrix is usually a transition matrix whose entries represent the probabilities of moving between states or vertices in a graph.
2. How is a transition matrix calculated?
Divide each adjacency-matrix row by its sum. Every nonzero row then sums to one, giving the probability of selecting each possible destination.
3. What is a stationary distribution?
It is a probability vector that remains unchanged after multiplication by the transition matrix: πP = π.
4. What is the stationary distribution of an undirected graph?
For a finite connected undirected weighted graph, each vertex's stationary probability is proportional to its weighted degree.
5. Does every random walk converge?
Not necessarily. A finite irreducible chain has a unique stationary distribution, but convergence from every initial distribution additionally requires aperiodicity.
6. Why can a random walk oscillate?
Periodic network structures can force the walk to alternate between groups of vertices. A walk on a bipartite graph without self-loops is a common example.
7. What is the difference between a random walk and a Markov chain?
A random walk is a particular type of Markov chain in which transitions are typically associated with movement through a graph or network. A Markov chain is the broader mathematical framework for systems with probabilistic state transitions.
8. What does a row-stochastic matrix mean?
It is a matrix with nonnegative entries in which every row sums to one. Each row can therefore represent a probability distribution over possible next states.
9. Can adjacency matrices contain weights?
Yes. Weighted adjacency matrices represent stronger or weaker connections. The transition probability is proportional to the corresponding edge weight.
10. What is the difference between a stationary distribution and visit frequency?
A stationary distribution is a mathematical probability vector satisfying πP = π. Visit frequency is an empirical estimate obtained by observing simulated walks. The empirical frequency approaches the stationary distribution under suitable long-run conditions.
Related Matrix Calculators
Explore other interactive tools for Markov chains, matrix powers, eigenvalues and numerical methods.