Home > Python > Application in Statistical Mechanics

Ch. 21.6 2D Random Walk Simulation

Chapters Index
Program 1

2D Random Walk Simulation

Python 3.11 Ready

                                
Click "Run Code" to execute script and render figures.

Mathematical Problem Formulation

2D RW Simulation
Program 2

2D Random Walk Simulation

Python 3.11 Ready

                                
Click "Run Code" to execute script and render figures.

Mathematical Problem Formulation

RMS distance in 2D RW
Program 3

2D Random Walk Simulation

Python 3.11 Ready

                                
Click "Run Code" to execute script and render figures.

Mathematical Problem Formulation

3D RW Simulation
Program 4

2D Random Walk Simulation

Python 3.11 Ready

                                
Click "Run Code" to execute script and render figures.

Mathematical Problem Formulation

RMS distance in 3D RW
Theoretical Principles & Computational Physics Guide

2D Random Walk Simulation: Statistical Physics & Stochastic Modeling

Dr. Alorika Chatterjee & Dr. Anirban Shaw Science & Physics Learners Python 3 / NumPy / SciPy

1. Core Principles & Theoretical Framework

Stochastic Processes: Simulates random physical phenomena including Brownian diffusion, radioactive decay, and thermal fluctuations.
Ensemble Averages: Computes macroscopic thermodynamic observables as statistical ensemble averages over microscopic configurations.
Monte Carlo Convergence: Statistical error scales inversely with the square root of trial count: $\sigma \propto 1/\sqrt{N}$.

2. Mathematical Formulation & Algorithmic Pipeline

Random walk diffusive spreading and Monte Carlo error scaling:

$$ \langle x(t) \rangle = 0, \quad \langle x^2(t) \rangle = 2 D t, \quad \text{Statistical Uncertainty: } \sigma_N = \frac{\sigma}{\sqrt{N}} $$

3. Numerical Mechanics & Implementation Logic

  • Random Number Seeding: Initialize pseudo-random generators with fixed seeds to ensure reproducible simulation results.
  • Ensemble Sampling: Execute $M$ independent trials of $N$ steps each to build accurate probability distributions.
  • Histogramming: Bin particle final positions to verify convergence toward Gaussian/Poisson distributions.

4. Relevant Computational Practice Exercises

Exercise 1
Simulate $M = 1000$ independent random walk trajectories and confirm that root-mean-square displacement scales as $\sqrt{t}$.
Exercise 2
Apply Monte Carlo integration to estimate $\pi$ using hit-or-miss circle sampling and plot error vs trial count $N$.
Exercise 3
Model radioactive nuclear decay for $N_0 = 10^4$ nuclei and compare against the continuous decay law $N(t) = N_0 e^{-\lambda t}$.
Standard Literature & References:
  • F. Reif, "Fundamentals of Statistical and Thermal Physics", Waveland Press (2009).
  • Mark Newman, "Computational Physics", University of Michigan (2013).