RandomWalk is a C# Windows application that I developed for homework in my Statistical Mechanics class. The application graphs 1-D and 2-D random walks. It also graphs the histogram of endpoints for an ensemble of 1D random walks. RandomWalk is a solution to Exercise 2.5 in Dr. James Sethna’s Statistical Mechanics: Entropy, Order Parameters, and Complexity.
You can get the RandomWalk application and its source code on GitHub.
Here’s some background on random walks. A random walk is a series of steps, each having the same length and going in a random direction. In one dimension, the random steps can go left or right. In two dimensions, the random steps can go left, right, up, or down.
Now it turns out that if you have many walkers all starting at the same starting location and you record where they end up, the most likely end point is exactly the starting location. The least likely end point is the furthest possible distance away from the starting location. The graph of these points approximates a bell curve (also called a normal distribution or a Gaussian distribution). In mathematics, the explanation of this phenomenon is called the Central Limit Theorem.
If you would like to see the bell curve in the RandomWalk application, try using the following values:
- Number of Steps: 3 (if the walkers move only one step, they cannot return to the starting location)
- Number of Walkers: 100000 (this is the key to getting the bell curve shape, there needs to be enough random walks for the histogram of their endpoints to “smooth” out)
- Number of Dimensions: 1 (the RandomWalk program only graphs the histogram for 1-D walks)
- Number of Bins: 100 (this parameter just lumps the random walks into a discrete number of bins – so instead of 100000 points on your graph, you only have 100 points)