Order to Disorder
¡@¡@A box is divided into 2 equal parts by a partition with a small hole. The left half contains 100 particles and the right part is empty.

¡@¡@For assumptions, the particles do not interact with one another so that the probability per unit time that a particle goes through the hole is the same for all particles regardless of the number of particles in either half. That is to say, each particle has the same chance to go through the hole, the probability per unit time that a particle moves from left to right equals the number of particles on the left side divided by the total number of particles. Besides, the size of the hole is such that only one particle can pass through it in one unit of time.

¡@¡@We can predict that after some time, the system reaches equilibrium. The average number of particles in each half of the box is 50. The red curve in the above Java Applet shows the number of particles in the left partition decreases in time from its initial value to its equilibrium value.
¡@¡@If there are n(t) particles on the left side after t unit time, then the change in n(t) in the time interval Δt is given by

¡@¡@If we treat n and t as continuous variables and take the limit Δt -> 0, we have

¡@¡@The solution of the above differential equation (the black curve in the Java Applet) with initial condition n(t=0)=N is

Algorithm:
  1. For Loop from 0 to total time T
  2. Generate a random number p where 0 < p < 1.
  3. Compare p to the current value of the fraction of particles n/N on the left side of the box.
  4. If p < n/N, a particle is moved from left to right.
  5. Otherwise, a particle is moved from right to left.
  6. End of For Loop