Monte Carlo demonstrations: Importance sampling, Rejection sampling, Metropolis method, and Slice Sampling
(c) David J.C. MacKay
| Lecture course |
Book |
Other demonstrations |
Overview
This sequence of demonstrations, which takes about an hour to get through
if explained in detail, covers all the core Metropolis methods that can be rendered
in one dimension.
Requirements
This demonstration should work if you are running X-windows on a
unix machine that has octave and gnuplot.
If you have got octave and gnuplot on some other system (eg cygwin under Windoze),
it may work.
To run the demonstration:
- get the demonstration files (41K)
by clicking here http
/ ftp
- unpack thus:
tar zxvf mcmc.tar.gz
This unpacks a load of files into a directory
called mcmc. [If there are any complaints about the clock time use
tar zxvfm mcmc.tar.gz]
cd mcmc
- (optional)
modify your X windows defaults so that the gnuplot colours and fonts
come out right. (Execute this command on the machine running X windows.)
xrdb -load Xdefaults.gnu
octave
(Works fine with octave-2.0 but not with octave-2.1.33, which seems to
have plotting bugs.)
- To run the demo:
load 'DEMO'
Select from a range of demonstrations. If you keep hitting return you
will be taken through the sequence
- Importance sampling
- Rejection sampling
- Metropolis method
- Slice sampling
by selecting option [14] you can switch between two alternative
target densities P*(x); the second one being more wiggly than the first.
Commentary
David MacKay <mackay@mrao.cam.ac.uk>
Last modified: Mon Feb 17 14:53:31 2003