Skip to content

Java and Processing implementations for visualising various MCMC methods.

License

Notifications You must be signed in to change notification settings

shermanlo77/oxwasp_exchange_mcmc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

95 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

oxwasp_exchange_mcmc

Java implementations of the Metropolis-Hastings (Metropolis et al., 1953) (Hastings, 1970), Adaptive Metropolis-Hastings (Haario et al., 2001) (Roberts and Rosenthal, 2009), Hamiltonian Monte Carlo (Neal, 2011), No U-Turn Sampler (Hoffman and Gelman, 2014) including the dual averaging version and Elliptical Slice Sampler (Murray et al., 2010).

Also included are Processing implementations of the algorithms for visualising these algorithms sampling a 2D Normal distribution.

For dependencies, see the pom.xml file or:

How to use (Linux recommended)

Download from the .jar file from the release or compile it using the instructions below. Call the .jar file using

java -jar oxwasp_exchange_mcmc-1.0.0-jar-with-dependencies.jar -option

where -option can be one of the following options below. Click on pause to pause the simulation, once paused, click on step to run the simulation one step at a time. Click on quit to quit the simulation.

-bm Brownian Motion

Click on the screen to start a Brownian motion.

alt text

-rwmh Random walk Metropolis-Hastings

Click and drag to create a circle, the radius correspond to the proposal distribution. Release to create a random walk Metropolis-Hastings. Green dots represent accepted steps and red dots represent rejected steps. Check on adaptive to adapt the proposal distribution.

alt text

-hmc Hamiltonian Monte Carlo

Click on the screen to start a Hamiltonian Monte Carlo. The yellow dots show the leap frog steps. Slide the slider to change the number of leap frog steps.

alt text

alt text

-nuts No U-Turn Sampler

Click on the screen to start a No U-Turn Sampler. The yellow dots show the leap frog steps and the blue dot shows the accepted sample from those leap frog steps.

alt text

-slice Elliptical Slice Sampler

Click on the screen to start an elliptical slice sampler. The next step of the chain is searched for on the ellipse. The yellow sections show acceptable regions of the ellipse. The red sections show unacceptable regions of the ellipse. Red dots shows rejected samples.

alt text

How to compile (Linux recommended)

Maven required.

Clone this repository.

Download g4p_controls G4P (GUI for processing) version 4.1.5 and locate G4P.jar. Install it using

mvn install:install-file -Dfile=./G4P.jar -DartifactId=g4p_controls -DgroupId=g4p_controls -Dversion=4.1.5 -Dpackaging=jar

Go to the repository and run

mvn package

and the .jar files are located in target/.

References

  • Haario, H., Saksman, E., Tamminen, J., et al. (2001). An adaptive Metropolis algorithm. Bernoulli, 7(2):223-242.
  • Hastings, W. K. (1970). Monte Carlo sampling methods using Markov chains and their applications. Biometrika 57(1):97-109.
  • Hoffman, M. D. and Gelman, A. (2014). The No-U-turn sampler: Adaptively setting path lengths in Hamiltonian Monte Carlo. Journal of Machine Learning Research, 15(1):1593-1623.
  • Metropolis, N., Rosenbluth, A. W., Rosenbluth, M. N., Teller, A. H., and Teller, E. (1953). Equation of state calculations by fast computing machines. The Journal of Chemical Physics, 21(6):1087–1092.
  • Murray, I., Adams, R. P., and MacKay, D. J. (2010). Elliptical slice sampling. In Proceedings of the 13th International Conference on Artificial Intelligence and Statistics.
  • Neal, R. M. (2011). MCMC using Hamiltonian dynamics. In Brooks, S., Gelman, A., Jones, G., and Meng, X.-L., editors, Handbook of Markov Chain Monte Carlo, chapter 5, pages 113–162. CRC press.
  • Roberts, G. O. and Rosenthal, J. S. (2009). Examples of adaptive MCMC. Journal of Computational and Graphical Statistics, 18(2):349–367.