What this shows
Each colored path is one walker. All walkers start at the same point (the center of the viewport) and move independently. At every step, a walker picks a direction uniformly at random and moves a fixed distance in that direction. This is often called an isotropic or Pearson random walk in the plane. With Step directions set to the grid, each step instead goes up, down, left or right with equal probability: the simple random walk on the square lattice.
How the visualization works
- The simulation keeps only the current position of every walker. It advances in whole, discrete steps, so frame rate never changes the outcome.
- Every random direction comes from a seeded pseudo-random generator. The same seed, walker count and step size always produce the same paths, which is why the seed is part of the shareable URL.
- The renderer draws the segment each walker covered since the previous frame into an offscreen texture. At high speeds several steps can happen between frames, and the drawn segment then joins the sampled positions rather than every intermediate step.
Parameters
- Walkers: how many independent walkers to simulate. Changing it restarts the run from the seed.
- Step size: the length of each step, in screen pixels. Applies immediately.
- Speed: steps per second. Applies immediately.
- Step directions: any direction, or only the four grid directions. Restarts the run.
- Show trails: draw each walker's path, or only its current position. Applies immediately and never changes the walk itself.
Mathematical background
Write the position of one walker after steps as , where each step has length and a random direction (uniform on the circle, or one of the four grid directions), independent of the others. Each step has mean zero, so the expected position stays at the origin. For the squared distance, the cross terms vanish for , leaving
The typical (root-mean-square) distance from the start therefore grows like : to get twice as far, a walker needs about four times as many steps. You can see this in the way the cloud of walkers spreads quickly at first and then more and more slowly.
By the central limit theorem, for large the distribution of approaches a two-dimensional Gaussian. Rescaled appropriately, random walks converge to Brownian motion, which connects this picture to diffusion.
The two choices of step directions differ step by step but not on large scales. In both, each coordinate of a step has mean zero and variance , and the two coordinates are uncorrelated, so both walks have the same Gaussian limit. Zoomed out, a cloud of grid walkers spreads just as round as the isotropic one.
References
The problem was posed by Karl Pearson in a 1905 letter to Nature and answered by Lord Rayleigh in the same volume. Full citations are listed below.
- Karl Pearson. The Problem of the Random Walk (1905). Nature 72, 294. Pearson's letter posing the problem.
- Lord Rayleigh. The Problem of the Random Walk (1905). Nature 72, 318. Rayleigh's reply to Pearson's letter.