We have provided some sample code to help you understand MCMC techniques such as Gibbs sampling, Metropolis, and Gibbs-Metropolis.

Note that all of the faculty examples use the data in faculty.dat

Rejection Sampling

Recall that rejection sampling is not effective with continuous-valued evidence nodes. However, we include it here because it's simple.

fac-rejection.py

Likelihood Weighting

Gibbs Sampling

In the following example, Gibbs sampling is used with sampling from the complete conditionals.

fac-gibbs.py

Metropolis

In the following example, the Metropolis algorithm is used to sample from a Cauchy distribution.

cauchy.py

Gibbs-Metropolis Combo

This code implements a combo MCMC algorithm using Gibbs sampling, with Metropolis sampling at each node:

fac-combo.py

Evilplot

Evilplot files are listed below. A simple way to get everything needed for evilplot is to run the following command:

  git clone git://aml.cs.byu.edu/evilplot.git

__init__.py

param.py

plot.py

plotitems.py

util.py

cs-677/sampling-sample-code.txt · Last modified: 2015/01/06 21:12 by ryancha
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0