Skip to content
forked from rueberger/MJHMC

Python implementation of Markov Jump Hamiltonian Monte Carlo

License

Notifications You must be signed in to change notification settings

schevalier/MJHMC

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Markov Jump Hamiltonian Monte Carlo

Python implementation of Markov Jump HMC

Markov Jump HMC is described in the paper

A. Berger, M. Mudigonda, M. R. DeWeese and J. Sohl-Dickstein
A Markov Jump Process for More Efficient Hamiltonian Monte Carlo
arXiv preprint arXiv:1509.03808, 2015

Example Python Code

from mjhmc.samplers.markov_jump_hmc import MarkovJumpHMC
import numpy as np

# Define the energy function and gradient
def E(X, sigma=1.):
    """ Energy function for isotropic Gaussian """
    return np.sum(X**2, axis=0).reshape((1,-1))/2./sigma**2
    
def dEdX(X, sigma=1.):
    """ Energy function gradient for isotropic Gaussian """
    return X/sigma**2

# Initialize the sample locations -- 2 dimensions, 100 particles
Xinit = np.random.randn(2,100)

# initialize the sampler.
sampler = MarkovJumpHMC(Xinit, E, dEdX, epsilon=0.1, beta=0.1)
# perform 10 sampling steps for all 100 particles
X = sampler.sample(num_steps = 10)
# perform another 10 sampling steps
X = sampler.sample(num_steps = 10)

Dependencies

Required

  • numpy
  • scipy
  • pandas

Optional

  • matplotlib
  • nosetests
  • seaborn (for making pretty plots)
  • spearmint (for hyperparameter optimization)

About

Python implementation of Markov Jump Hamiltonian Monte Carlo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%