These particles are following a random walk, or brownian motion. At each time step, we get a random direction in space for each particle and move it towards that direction.

[begin-latex]\left\{ \begin{align*} &\theta \sim U(0, 1) \\ &x_{t+1} = x_t + r \cos(2\pi\theta) \\ &y_{t+1} = y_t + r \sin(2\pi\theta) \end{align*} \right.[end-latex]

Mean Squared Displacement

This is the mean squared displacement over time. It is the average distance of a particle to its initial starting point (here, the center of the canvas).

[begin-latex]MSD = \frac{1}{n} \sum_{x,y} = (x_t - x_0)^2 + (y_t - y_0)^2[end-latex]

The theory predicts that MSD should be equal to [begin-latex-inline]2nDt[end-latex-inline], where:

This is just a line equation, which we can verify with the plot above. In our case [begin-latex-inline]MSD=4Dt[end-latex-inline], and, fitting a line on the data, we find that [begin-latex-inline]D \approx[end-latex-inline]?.