Mixing time for an inhomogeneous system¶
Create a system with two different colored particles (and different sizes if you are ambitious). Have the particles spatially separated. Explore how long is needed for the system to become uniform as a function of the number of particles and the initial density. To compare two distributions we can use the Kolmogorov-Smirnov test, from scipy. Talk with a member of staff how this works.
The following example compares 5000 random points to the uniform distribution. We want the first value of the "statistic". In this example it is close to zero showing that the random points are "close" to the uniform distribution. The statistic is between 0 and 1, and for $N$ samples is close to $1/\sqrt{N}$ if the distributions are identical.
In [3]:
import numpy as np
import scipy
a = np.random.uniform(size=4999)
print(scipy.stats.kstest(a, 'uniform'))
KstestResult(statistic=0.012921017084608244, pvalue=0.37113846926778804)