Worked Animation Example with Graphics Primitives: Visualizing the Random Walk

Many processes in the natural world can be modelled by random walks. An example is the trajectory of a particular  molecule in a gas at low pressure.  The next few lines of code produce random walks and display them graphically:

"index_138.gif"

"index_139.gif"

"index_140.gif"

"index_141.gif"

"index_142.gif"

"index_143.gif"

"index_144.gif"

Create a function that returns a graphic object putting the step number at the correct place:

"index_145.gif"

"index_146.gif"

"index_147.gif"

Create a function that returns a graphic object connecting a line between the current position and the previous.

"index_148.gif"

"index_149.gif"

"index_150.gif"

We can animate the jumps, but the result will not be satisfactory because each frame will be a different size...

"index_151.gif"

"index_152.gif"

If we use the PlotRange from a graphical object that contains all the points, we can fix the framesize, we use AbsoluteOptions

"index_153.gif"

"index_154.gif"

"index_155.gif"

"index_156.gif"

The animation is more satisfactory if we include the history... here we create a table of objects leading up to the current step.

"index_157.gif"

"index_158.gif"


Created by Wolfram Mathematica 6.0  (28 August 2007) Valid XHTML 1.1!