This work presents a computational simulation of a 3D stochastic random walk system combined with a density-based visualization model. A set of particles evolves inside a bounded cubic space, where each particle moves randomly along one of the three axes at each iteration. The system visualizes both spatial distribution and local density using a real-time 3D scatter plot with color mapping.
This work implements a discrete random walk simulation in a bounded 3D grid with the following objectives:
- Simulate stochastic movement of multiple particles in 3D space.
- Constrain motion inside a finite cubic domain using wrap-around behavior.
- Compute local spatial density of particle distributions.
- Visualize particle evolution in real time using Matplotlib 3D rendering.
- Encode density information into color intensity for visual interpretation.
The system is designed as an exploratory tool for understanding diffusion-like processes and emergent spatial clustering in stochastic systems.
The simulation operates on a discrete 3D lattice defined as:
Where:
-
$G \in \mathbb{N}$ : grid size (spatial boundary) -
$N \in \mathbb{N}$ : number of particles
Each particle
The system state at time
At each iteration, every particle performs a stochastic update:
- A random axis is selected:
$x$ ,$y$ , or$z$ . - A random step is chosen:
$+1$ or$-1$ . - Position is updated using modular arithmetic:
This ensures:
- Constrained motion within bounds.
- Toroidal (wrap-around) space topology.
- No particle loss at boundaries.
To analyze spatial clustering, a density metric is computed:
Where:
-
$\text{count}(p_i)$ is the number of occurrences of position$p_i$ . -
$\max(\text{counts})$ is the highest frequency among all positions.
This produces a normalized density value in the range
The system produces:
- Emergent clustering patterns in bounded space.
- Density heatmaps over 3D scatter distributions.
- Dynamic diffusion-like behavior over time.
Higher iteration counts reveal:
- Region concentration effects.
- Random equilibrium distribution.
- Local clustering persistence due to discrete collisions.
- Density computation is
$\mathcal{O}(n^2)$ . - Visualization re-creates scatter plot each frame.
- No physical forces (purely stochastic motion).
- Discrete grid approximation may introduce aliasing effects.