##### Differences

This shows you the differences between two versions of the page.

 — cs-677:sampling-sample-code [2015/01/06 21:12] (current)ryancha created 2015/01/06 21:12 ryancha created 2015/01/06 21:12 ryancha created Line 1: Line 1: + 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 [http://​aml.cs.byu.edu/​~kseppi/​677/​clone/​cs677/​gibbs/​faculty.dat 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. + + [http://​aml.cs.byu.edu/​~kseppi/​677/​clone/​cs677/​rejection/​fac-rejection.py fac-rejection.py] + + == Likelihood Weighting == + + [http://​aml.cs.byu.edu/​~kseppi/​677/​clone/​cs677/​likelihood-weighting/​fac-lw.py fac-lw.py] + + == Gibbs Sampling == + + In the following example, Gibbs sampling is used with sampling from the complete conditionals. + + [http://​aml.cs.byu.edu/​~kseppi/​677/​clone/​cs677/​gibbs/​fac-gibbs.py fac-gibbs.py] + + == Metropolis == + + In the following example, the Metropolis algorithm is used to sample from a Cauchy distribution. + + [http://​aml.cs.byu.edu/​~kseppi/​677/​clone/​cs677/​metropolis/​cauchy.py cauchy.py] + + == Gibbs-Metropolis Combo == + + This code implements a combo MCMC algorithm using Gibbs sampling, with Metropolis sampling at each node: + + [http://​aml.cs.byu.edu/​~kseppi/​677/​clone/​cs677/​gibbs-metropolis/​fac-combo.py 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 + + [http://​aml.cs.byu.edu/​~kseppi/​677/​clone/​evilplot/​__init__.py __init__.py] + + [http://​aml.cs.byu.edu/​~kseppi/​677/​clone/​evilplot/​param.py param.py] + + [http://​aml.cs.byu.edu/​~kseppi/​677/​clone/​evilplot/​plot.py plot.py] + + [http://​aml.cs.byu.edu/​~kseppi/​677/​clone/​evilplot/​plotitems.py plotitems.py] + + [http://​aml.cs.byu.edu/​~kseppi/​677/​clone/​evilplot/​util.py util.py] 