PhysSandbox
Classical MechanicsWaves & SoundElectricity & MagnetismOptics & LightGravity & OrbitsLabs
🌙Astronomy & The Sky🌡️Thermodynamics🌍Biophysics, Fluids & Geoscience📐Math Visualization🔧Engineering🧪Chemistry

More from Math Visualization

Other simulators in this category — or see all 47.

View category →
FeaturedSchool

Vector Addition

Place vectors and see the resultant with head-to-tail animation.

Launch Simulator
FeaturedSchool

Trigonometry Circle

Unit circle with live sin, cos, tan values as you drag.

Launch Simulator
Kids

Function Grapher

Enter f(x) and see instant plots with zoom and pan.

Launch Simulator
FeaturedSchool

Fourier Series

Build waveforms from sine waves. Add harmonics one by one.

Launch Simulator
NewSchool

FFT Magnitude Spectrum

Paint or preset a 256-point signal; radix-2 FFT shows |X[k]| vs bin (DC to Nyquist).

Launch Simulator
NewUniversity / research

2D Phase Portrait (ODE)

Direction field and click-to-trace trajectories for planar systems: harmonic, damped, saddle, nodes, foci, pendulum (RK4).

Launch Simulator
PhysSandbox

Interactive physics, chemistry, and engineering simulators for students, teachers, and curious minds.

Physics

  • Classical Mechanics
  • Waves & Sound
  • Electricity & Magnetism

Science

  • Optics & Light
  • Gravity & Orbits
  • Astronomy & The Sky

More

  • Thermodynamics
  • Biophysics, Fluids & Geoscience
  • Math Visualization
  • Engineering
  • Chemistry

© 2026 PhysSandbox. Free interactive science simulators.

PrivacyTermsContact
Home/Math Visualization/Random Walk (2D / 3D Lattice)

Random Walk (2D / 3D Lattice)

This page simulates simple symmetric random walks on the d-dimensional cubic lattice Z^d with nearest-neighbor steps (four directions in 2D, six in 3D), all of unit length. A synchronized ensemble of independent walkers starts at the origin; after each clock tick every walker takes one independent step, and the simulator records the sample mean of r² = x² + y² (+ z²), which tracks the exact identity E[r²] = t for unbiased NN walks (diffusion scaling). A reference line y = t is overlaid on the ⟨r²⟩ vs t plot. A histogram of r² across walkers at the current time illustrates the spread around the mean. Separately, Monte Carlo paths started at the origin estimate first-return statistics: time τ of the first visit to 0 after t > 0. In 2D the walk is recurrent (almost surely returns), while in 3D it is transient with a nonzero escape probability, so the empirical return probability before a large cutoff visibly drops when switching dimensions—pedagogy for Pólya’s theorem and Green’s function intuition without heavy analysis.

Who it's for: Undergraduates learning probability, diffusion, or statistical physics who already saw informal random walks and want lattice SRW, MSD scaling, and recurrence in one interactive view.

Key terms

  • Simple random walk
  • Lattice Z^d
  • Mean squared displacement
  • Diffusion
  • First return time
  • Pólya recurrence
  • Transience

Lattice walk

192
8
12000
10

Independent walkers share the same clock: sample mean of r² tracks E[r²]=t on Z^d NN. First-return uses separate Monte Carlo paths from the origin; in 3D many paths are censored (transience).

Shortcuts

  • •Space / Enter — run / pause
  • •P — pause / resume
  • •R — reset walk & counters

Measured values

Global step t0
⟨r²⟩ now0.00
P(return) est.—
Median τ (returns)—
MC attempts0

How it works

Nearest-neighbor simple random walk on Z² or Z³: synchronized ensemble mean ⟨r²⟩ vs time with the identity line, histogram of squared radii across walkers, and Monte Carlo first-return statistics contrasting recurrent 2D with transient 3D walks.

Key equations

⟨S_t⟩ = 0, unit NN step: E[||S_t||²] = t; first return τ = inf{t>0 : S_t=0} (2D recurrent a.s., 3D finite prob per infinitely long walk).

Frequently asked questions

Why is the dashed reference line y = t, not 2t or 6t?
Each NN step has unit Euclidean length, so one step adds 1 in expectation to ||S||² for unbiased symmetric walks on Z^d in this normalization. If you doubled step length, both the walk and the identity would rescale accordingly.
What does “P(return) est.” mean with a finite cutoff?
Each Monte Carlo trial stops either at the first return time τ or after τ_max steps without returning. The displayed fraction counts returns before censorship; in 3D many long paths would need enormous τ_max to approximate the true return probability, so treat the readout as a finite-horizon Monte Carlo estimate.
How does this differ from the existing “Random Walk” math lab?
The older page emphasizes 1D coin flips and 2D fixed-length random-angle steps for visual trails. This lab uses integer lattice dynamics, an ensemble mean ⟨r²⟩, a histogram, and first-return Monte Carlo aimed at recurrence vs transience.