MCRobot (Markov Chain Robot) is a simulation program written for 32-bit Microsoft Windows operating systems that illustrates principles involved with the Markov Chain Monte Carlo (or MCMC) methods currently used in Bayesian statistical analyses.
MCRobot was originally written for the purpose of generating figures for the following paper:
Paul O. Lewis
Department of Ecology and Evolutionary Biology
The University of Connecticut
75 North Eagleville Road Unit 3043
Storrs, CT 06269-3043
Ph: (860) 486-2069
Fax: (860) 486-6364
Email: paul.lewis@uconn.edu
WWW: http://lewis.eeb.uconn.edu/lewishome/
Ctrl-F
and continue walking
the robot using Ctrl-N
. Initially, the landscape has no topography,
so the robot simply wanders aimlessly about. The robot walks in hops of varying
length and changes direction randomly after each hop. A single Ctrl-F
or Ctrl-N
keystroke results in 100 hops (by default), with each endpoint
marked by a colored dot and the path marked by a colored line.
The program is more interesting once at least one hill has been defined. Hills are represented by bivariate normal densities. To create a hill, drag the mouse (using the leftmost button) across the window to create a small box (don't make the box big; about one tenth of the diameter of the window is good for starters). The dimensions of the box determine the mean and standard deviation of each of the two variables of the bivariate normal density. (The standard deviation is constrained to be the same for each dimension.) Once the mouse button has been released, a dialog box will appear allowing you to refine the parameters governing the hill you just created. Things you might wish to change at this point include: (1) the name of the hill; (2) the correlation coefficient (e.g., to make a ridge from lower left to upper right, use a coefficient of about 0.8); and (3) the weight (used to determine how "high" this hill is relative to other defined hills).
Once a hill is defined, it will be shown on the background by two yellow contours. The inner contour defines the region of 50% probability, whereas the outer contour circumscribes the region containing 95% of the probability for that particular bivariate normal hill.
After defining one or more hills, the robot will spend most of its time around the defined hills. The points representing the hop endpoints will be distributed according to the overall density defined by the mixture of bivariate normal hills on the landscape. To see just the points without the lines connecting them, uncheck the Show trajectory box in the dialog box invoked by the Robot | Options... menu item. This dialog box allows you to modify a number of other parameters as well, including the size of the dots used to denote hop endpoints (the Dot radius), the number of hops to take at one time (the Number of steps per walk), and the hill definition parameters. The position at which the robot begins its walk can also be set, as can the average length of each hop. The hop length is determined by gamma distributed random deviates. The Robot | Options... dialog box allows you to change the mean and standard deviation of the hops.
The original MCRobot has been upgraded to allow multiple chains to be run simultaneously, with all chains except one (the "cold" chain) experiencing a posterior density (landscape) that has been flattened to varying degrees by raising the posterior density to a power between 0 and 1. The cold chain is always the blue one (naturally), with the hottest chain being the red one. Chains heated to intermediate degrees have intermediate colors. The power used for each chain is 1/k, where k is the chain's rank (cold chain is 1, first heated chain is 2, etc.). Thus, the chain of rank 4 experiences a density that has been raised to the power 0.25. The colors used for these chains do not scale the same way: I simply use wavelength 450 nm for the coldest chain, 730 nm for the hottest chain, and determine the colors of intermediate chains by dividing up the total interval into equal pieces. Thanks to Dan Bruton (http://www.physics.sfasu.edu/astro/color/spectra.html) for making code available to translate wavelengths into RGB color triplets!
The sampled landscape is by default show from a vantage point directly above
the field on which the imaginary robots are moving. You may wish to view the
landscape from a different angle. To do this, you must check allow rotation
from the Robot | Options... dialog box (Ctrl-R
toggles
this feature on and off). (Note: this will cause any points you have already
generated to disappear.) Once new points have been generated, click (and hold
down) the right mouse button over the main window. This will change the display
to show a wire-frame pyramid to use as a guide in choosing a new viewing angle
(Note: initially you will be viewing the pyramid from directly above, so it
will only being looking like a pyramid after you rotate it a bit). Still holding
down the right mouse button, move the mouse up slowly. This will rotate the
pyramid. Once the pyramid is at a viewing angle that is desirable, release the
right mouse button to view the landscape at that angle. This feature is initially
turned off because viewing things in 3D requires saving the third dimension
(one more value to save for every point). Thus, if memory is at a premium, avoid
checking the allow rotation box, or limit the number of points you
generate.
Ctrl-C
)
Ctrl-T
) when using multiple chains,
because these swaps result in a tangled web of lines that is somewhat distracting.F1
).
F2
)
F3
)
F4
)
F5
).
Ctrl-O
)
Ctrl-F
)
Ctrl-N
)
Ctrl-T
)
Ctrl-R
)
Ctrl-L
)
Ctrl-S
)