Visualizing random walks

Today, a science lesson delivered via Mathematica. Imagine a pawn on a chessboard. Instead of marching steadily forth, this pawn has gone renegade. In fact, it has gone completely mad, and without respect to the rules, is shuttling randomly forward and backward. Every time it is your turn, it is equally likely to: 1) not move at all, 2) move forward, 3) move backward.

Such a monstrously aimless behavior is called in mathematics a random walk.

Here is some Mathematica code to simulate a random walk, and to collect the statistics of many such simulations.

Random walk code

What does a random walk look like? If time is vertical and the progress of the random walker is horizontal, one particle performing 50 steps of a random walk looks something like this:

Trajectory of single random walk

What about if one superimposes many such walks?

Trajectory of single random walk

As you can see, with 5000 particles, the identity of each particle has begun to blur away, and now the whole ensemble starts to look a little bit more like a blob of ink diffusing on blotting paper.

This is not an accident. That is exactly what ink diffusing on blotting paper is: a near infinite number of molecules of ink, each one buffeted hither and thither by thermal vibrations, each performing what is called in the biz Brownian motion.

In fact, one of Einstein’s achievements (other than the various flavors of relativity, of course) was to show mathematically how this Brownian motion relates to the underlying atomic nature of matter.