Brownian motion
Simulate reproducible two-dimensional diffusion paths and compare ensemble MSD, one path and 4Dt.
About this tool
Two-dimensional diffusion
All N paths start at the origin. Each time step adds independent Gaussian increments to x and y, each with mean zero and variance 2DΔt. D is entered in µm²/s, positions are in µm and squared displacements are in µm². The time grid is tj=jT/steps, including exactly 0 and T, with Δt=T/steps. D=0 is a valid stationary case.
The model has no walls, collisions, inertia or flow. It is a diffusion model, not a resolved movie of molecular impacts. D is an input rather than an estimate from particle radius, viscosity or temperature.
Ensemble versus one path
At each time, ensemble MSD is Σ(xi²+yi²)/N. For one selected path, r²=x²+y² is its squared displacement from the origin. It is not travelled path length and not a time-averaged MSD. For the assumed independent Gaussian increments, the theoretical ensemble expectation is 4Dt, obtained by adding the two coordinate variances. A finite run fluctuates around this expectation; neither the ensemble curve nor a single path has to increase at every step.
The cloud and highlighted trajectory show the selected raster time. Their axes retain the full-run bounds and the same x/y scale. With no movement, the cloud uses a ±1 µm reference extent along the smaller plotting dimension. The statistics plot shows the whole computed run, including the selected path's r², plus a common cursor. Colour and line patterns distinguish the curves.
Reproducible run, separate playback
The limits are D from 0 to 100 µm²/s, T from 0.5 to 5 s, 1 to 400 paths and 20 to 500 steps. The seed is an integer from 0 to 2³²−1. A deterministic LCG uses state=(1664525·state+1013904223) modulo 2³² and u=(state+0.5)/2³². Two consecutive u values form a Box–Muller pair. Draws are ordered by time step, then path, then radius and angle. The seed is for reproducible teaching examples, not cryptography. Repeating the same complete configuration reproduces the run; changing the path count changes how later random draws are assigned.
Simulate explicitly generates the bounded run in cancellable portions and leaves the cursor paused at the final sample. Replay starts at zero; playback then moves through stored samples without drawing more random numbers. One step advances one raster position. Cursor, path selection and fit changes all reuse the same run. A long playback frame advances at most 0.25 s. Hiding the tool pauses playback and cancels unfinished generation; no elapsed wall time is caught up on return.
Fit with an intercept
The initial fit uses the whole ensemble series. From and To choose a closed interval with 0≤From<To≤T and at least two included sample times. A tiny endpoint tolerance of at most 4·Number.EPSILON·max(|t|,|From|,|To|,1) seconds only compensates floating-point representation; it does not round the interval to whole steps. The actual first and last included times and the number of points are shown.
Ordinary least squares fits MSD=m·t+b using centred sums: m=Σ(t−t̄)(MSD−MSD̄)/Σ(t−t̄)² and b=MSD̄−mt̄. The slope estimate gives Dfit=m/4. The intercept is not forced to zero, and the line is drawn only between the used sample times. Editing the interval removes the old fit until Fit interval is pressed.
Short or fluctuating intervals can give a negative slope and negative Dfit; this estimate remains visible and is not a physical negative diffusivity. MSD values at different times are correlated, so no ordinary independent-residual confidence interval is presented.
State and sources
Changing a model input invalidates the old run. Reset keeps the inputs. Returning within the same page session preserves the run, cursor, selected path and fit, with playback paused. Reloading restores valid model inputs only and requires Simulate again. Calculations and stored trajectories remain in the browser.
MIT/Bazant, Lecture 20, page 2 describes the Gaussian increment model and its limitations. The 2D expectation 4Dt follows here by adding independent coordinate variances. NIST: least squares gives the slope and intercept formulas.