Hundreds of independent walkers each take a real random step every tick — either a uniformly random angle or one of four lattice directions. No trajectory is scripted or decorative: the histogram of how far each walker has strayed from the origin, and the growth of the population's mean-squared displacement over time, are computed live from the actual random samples and checked against the closed-form predictions from probability theory.
By the Central Limit Theorem, after t independent random steps each coordinate of a walker's position is approximately Gaussian, so its radial distance from the origin follows a Rayleigh distribution. The histogram panel overlays this predicted curve directly against the measured bars, computed fresh from the current population every frame.
Switch between a free uniform-angle walk and a four-direction lattice walk, and adjust the walker count, step size and simulation speed. Watch the mean-squared-displacement panel: the green measured curve should track the yellow dashed 4Dt theory line, the hallmark of diffusive (as opposed to ballistic) motion.
The diffusive scaling MSD ∝ t (rather than ∝ t²) is what distinguishes random diffusion from directed motion. It is the same law Einstein derived in 1905 to explain Brownian motion, and it underlies models of heat conduction, gas diffusion, and even stock-price volatility.
This lab runs a real population of independent 2D random walkers and turns their raw step data into two live statistical instruments: a displacement histogram checked against the Rayleigh distribution predicted by the Central Limit Theorem, and a mean-squared-displacement (MSD) curve checked against the linear MSD = 4Dt diffusion law. Every bar and every plotted point is recomputed from the current walkers each frame — nothing is pre-rendered or scripted.
Each walker independently samples a real random step every tick: either a uniformly random direction of fixed length, or one of four lattice moves (N/S/E/W). The histogram bins the population's current distance from the origin and overlays the closed-form Rayleigh probability density that the Central Limit Theorem predicts for the sum of many independent 2D steps. The second panel tracks the population's mean-squared displacement over time against the theoretical straight line MSD = 4Dt, the signature of diffusive rather than ballistic motion.
Choose Uniform angle or Lattice N/S/E/W to change the step distribution. The Walkers slider (20–2000) sets the population size — more walkers make the histogram and MSD curve smoother and closer to theory. Step sets the per-step length, and Speed controls how many simulation steps run per rendered frame. Reset restarts every walker from the origin and clears the recorded history.
The mean-squared-displacement growing linearly with time (rather than with time squared) is the mathematical fingerprint of diffusion. It is exactly this scaling that let Jean Perrin experimentally confirm Einstein's 1905 theory of Brownian motion, providing the first direct evidence that atoms and molecules are real, physical objects.
This simulation runs hundreds to thousands of independent walkers simultaneously and aggregates their real positions into two statistical measurements — a displacement histogram and a mean-squared-displacement curve — rather than just animating one path. The value of a random walk in statistics comes from these population-level laws, not from watching a single trajectory.
The Central Limit Theorem says that the sum of many independent random steps approaches a Gaussian distribution regardless of the shape of each individual step. Since each walker's x and y coordinates are sums of many i.i.d. random steps, they become approximately Gaussian, which makes the radial distance from the origin follow a Rayleigh distribution — exactly the curve overlaid on the histogram.
Mean-squared displacement (MSD) is the average of the squared distance from the origin across all walkers. For ordinary diffusion it grows linearly with the number of steps t, following MSD = 4Dt in two dimensions, where D is the diffusion coefficient derived from the step-size distribution. A straight, linear MSD curve is the defining signature of diffusive random motion, as opposed to ballistic motion where MSD would grow as t².
Both step rules are calibrated to have the same per-axis step variance, so they diffuse at the same rate on average and share the same theoretical Rayleigh and MSD = 4Dt predictions, even though the underlying step-direction distributions are different (continuous angle vs. four fixed directions).
Walkers sets the population size from 20 to 2000 — larger populations converge to theory with less statistical noise. Step sets the fixed length of each individual step. Speed sets how many simulation steps are advanced per rendered frame, letting you fast-forward toward the long-time diffusive regime.