2D Random Walk Back
Probability & Diffusion

2D Random Walk Simulator

Watch multiple walkers diffuse in real time. The MSD log-log plot reveals the diffusion law. Switch between lattice, Gaussian, and Lévy flight walks.

Parameters

Number of walkers
Step size
X drift
Walk type
Boundary condition
Speed
Results
0
Steps
0.0
Current MSD
0.0
Theory 4Dt
0.0
Max disp.
Walk
Msd
Theory & Key Formulas
$$\langle r^2(t)\rangle = 4Dt$$
Normal diffusion MSD is linear in time. The log-log slope identifies the diffusion regime.

What is a 2D Random Walk?

🙋
What exactly is a "random walk"? It just looks like a bunch of dots wandering around randomly on the screen.
🎓
Basically, it's a mathematical model for the path of something that takes successive random steps. In this simulator, each "walker" is like a pollen grain being jostled by water molecules. Try hitting "Start" with just 1 walker and watch its path—it's the purest form of unpredictable motion.
🙋
Wait, really? So the "Mean Squared Displacement" (MSD) plot is measuring how "spread out" they get over time?
🎓
Exactly! The MSD, $\langle r^2(t)\rangle$, is the average squared distance from the starting point. For normal diffusion—like our pollen grain—theory says it grows linearly with time. You can see this by running the "Lattice" walk with many walkers and watching the blue MSD line. The red theoretical line, $4Dt$, should match it closely.
🙋
What happens when I switch from "Lattice" to "Gaussian" or "Lévy Flight" in the dropdown? The paths look totally different.
🎓
Great observation! You're changing the fundamental step rules. "Lattice" walks on a grid. "Gaussian" takes steps of any length, following a bell curve. "Lévy Flight" allows for rare, huge jumps. This changes the diffusion regime. Check the log-log MSD plot: a slope of 1 means normal diffusion. Try "Lévy Flight" and increase the "Step Power Law" slider—you'll see superdiffusion where the slope becomes greater than 1!

Physical Model & Key Equations

The core measure of a random walk is the Mean Squared Displacement (MSD). It quantifies how far the walkers have wandered, on average, after a certain time.

$$\langle r^2(t) \rangle = 2 D t$$

Here, $\langle r^2(t) \rangle$ is the mean squared displacement at time $t$, $D$ is the diffusion coefficient (which depends on step size and rate), and the factor 2 is for two dimensions. This linear relationship defines normal diffusion.

To identify different types of motion, we often use a power-law form and analyze it on a log-log plot.

$$\langle r^2(t) \rangle \propto t^{\alpha}$$

The exponent $\alpha$ is the anomalous diffusion exponent . On the simulator's log-log plot, the slope of the MSD curve is $\alpha$. If $\alpha = 1$, it's normal diffusion. If $\alpha \lt 1$, it's subdiffusion (trapped, crowded). If $\alpha \gt 1$, it's superdiffusion (directed or Lévy flight).

Real-World Applications

Pollution & Contaminant Spread: Modeling how a pollutant disperses in groundwater or air is a classic random walk problem. Engineers use these simulations to predict contamination plumes and design remediation strategies, often needing to account for anomalous diffusion in porous soils.

Financial Market Modeling: The random walk hypothesis suggests stock price movements are unpredictable, similar to a particle's Brownian motion. "Lévy flight" models, which you can simulate here, are used to better capture the rare, large price jumps (crashes or rallies) seen in real markets.

Animal Foraging Patterns: Many animals, from albatrosses to deer, do not search for food in simple Brownian paths. Biologists use Lévy flight models (switch the simulator to this mode) to describe patterns with many short moves and occasional very long jumps, which is an optimal search strategy in sparse environments.

Polymer Physics & Materials Science: The conformation of a polymer chain in a solution can be modeled as a random walk. Understanding whether its motion is normal or subdiffusive (slowed by obstacles) is key for designing gels, plastics, and pharmaceutical delivery systems.

Common Misconceptions and Points to Note

First, it's easy to think that "the diffusion coefficient D is a constant determined solely by the type of particle," but this is a misconception. For example, even the same molecule will diffuse at completely different speeds in water versus in oil. In this simulator, try setting the "Walker Type" to "Continuous," keeping the "Step Size" fixed, and moving the "Diffusion Coefficient" slider. You'll see the "liveliness" of the particle's motion change, right? This means the diffusion coefficient depends strongly on the "environment (e.g., viscosity)" and "temperature." In practice, the first step is correctly setting the value of D used in your simulation based on experimental or literature values.

Next, do not judge the MSD graph based on a single run. Especially when the number of walkers is low, the MSD plot can be quite scattered. If you run a "Lattice" walk with just 1 walker, you should see that the MSD does not form a perfect straight line. This is statistical fluctuation. To obtain reliable results, you need to run the simulation with a sufficient number of walkers (e.g., 100 or more) and take the average.

Finally, be careful when setting parameters for Lévy Flight. If you set the power exponent α to a value close to 2.0 (e.g., 2.1), it will appear almost indistinguishable from a normal random walk. To clearly see the characteristics of superdiffusion, set α between 1.5 and 2.0. However, if you set α too low (e.g., 1.1), extremely long jumps can occur, potentially causing the particle to immediately leap out of the simulation area. When applying this to real phenomena, a process of carefully estimating α from observational data is essential.

How to Use

  1. Set particle count (valN) between 100–10,000 particles; higher counts show ensemble statistics more clearly
  2. Configure step size (valStep) in micrometers: 0.1–10 μm typical for molecular diffusion studies
  3. Apply optional drift velocity (valDriftX) in μm/s to impose directional bias (0 for pure diffusion)
  4. Select walk mode: lattice for grid-based motion, Gaussian for continuous displacement, or Lévy for anomalous diffusion
  5. Adjust Lévy exponent (valAlpha) between 0.5–2.0; lower values produce heavy-tailed jumps
  6. Run simulation and observe mean-squared displacement (MSD) growth; MSD ∝ t validates diffusion coefficient estimation

Worked Example

Simulate colloidal gold nanoparticles (50 nm diameter) in water at 25°C. Set N=1000 particles, step size 0.5 μm, drift 0 μm/s (pure diffusion), Gaussian mode. After 500 time steps (Δt=1 ms each), MSD reaches approximately 2.5 μm². From Einstein relation D = MSD/(4t), calculated diffusion coefficient D ≈ 1.25×10⁻¹² m²/s, matching Stokes–Einstein prediction for this particle size and medium viscosity.

Practical Notes

  1. Lattice mode enforces discrete jumps (4-neighbor or 8-neighbor connectivity); use for polymer chain segments on fixed meshes
  2. Gaussian continuous walks approximate real Brownian motion; select for liquid-phase particle tracking experiments
  3. Lévy flights (α < 2) model superdiffusion in turbulent dispersion or anomalous transport in porous media; MSD grows as t^(α) rather than linear
  4. Drift velocity breaks symmetry; useful for simulating electrophoretic or pressure-driven transport superimposed on thermal diffusion
  5. Small step size (<0.1 μm) increases computation time but improves resolution; balance against physics timescale