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

Related simulators

Continue with similar topics in this category — or all 85 in Math Visualization.

View category →
NewSchool

Random Walk

Launch Simulator

1D or 2D steps; trail and running mean ⟨r²⟩ vs diffusion intuition.

NewSchool

Delaunay & Voronoi

Launch Simulator

Bowyer–Watson triangulation and dual Voronoi tessellation; click to add seeds, drag to move.

NewSchool

Tumor Growth (Gompertz / Logistic)

Launch Simulator

V(t) → plateau K: Gompertz rV ln(K/V) or logistic rV(1−V/K); chemotherapy as linear kill −kV; RK4 vs untreated reference.

NewSchool

K-Means Clustering (Lloyd)

Launch Simulator

Click to add points, choose k, randomize centroids, then step Lloyd iterations (assign to nearest centroid, update means). Optional Gaussian-mixture demo; watch within-cluster SSE decrease.

NewSchool

Toy 2-Layer MLP + Backprop (XOR / spiral)

Launch Simulator

Click-labeled 2D data; **tanh** hidden layer + **logistic** output trained by **full-batch** gradient descent on **binary cross-entropy**. Heatmap shows **P(class 1)** evolving across epoch blocks — watch the **0.5 decision contour** wrap XOR or untangle spirals.

NewUniversity / research

Monte Carlo Integration & Variance Reduction

Launch Simulator

Compare plain Monte Carlo, importance sampling, and stratified sampling for ∫f(x)dx, with convergence curves, standard error, and the 1/√N rate.

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)

Nearest-neighbor SRW on Z² or Z³: ensemble mean ⟨r²⟩ vs time with y = t reference, histogram of r² across walkers, and Monte Carlo first-return times (recurrent vs transient).

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

About this model

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

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.