Code Monkey home page Code Monkey logo

mcmc's Introduction

Getting Started

Copy the include folder to your project.

Example Usage (Random Walk a Normal distribution)

#include <mcmc/samplers/random_walk_metropolis_hastings_sampler.hpp>
#include <mcmc/markov_chain.hpp>

void main()
{
  Eigen::VectorXf initial_state(1);
  initial_state[0] = 450.0f;
  
  Eigen::MatrixXf covariance_matrix(1, 1);
  covariance_matrix.setIdentity();

  mcmc::random_walk_metropolis_hastings_sampler<Eigen::VectorXf, Eigen::MatrixXf> sampler(
    [ ] (const Eigen::VectorXf& state)
    {
      return normal_distribution_density(500.0f, 1.0f, state[0]);
    },
    covariance_matrix, 
    100.0f);

  mcmc::markov_chain<Eigen::VectorXf> markov_chain(initial_state);
  for(auto i = 0; i < 100000; ++i)
  {
    markov_chain.update(sampler);
    std::cout << markov_chain.state().format(Eigen::IOFormat()) << "\n";
  }
}

See the tests for the details and usage of individual samplers.

Notes

  • All kernel functions should return logarithmic scale values unless explicitly stated otherwise.
  • Boost/Math provides probability density functions for common distributions.

Coverage

The following list is based on Michael Clark's MCMC algorithms directory with a few extensions. Please feel free to add any missing samplers.

  • Adaptive Directional Metropolis-within-Gibbs
  • Adaptive Equi-Energy Sampler
  • Adaptive Griddy-Gibbs
  • Adaptive Hamiltonian Monte Carlo
  • Adaptive Metropolis
  • Adaptive Metropolis-within-Gibbs
  • Adaptive-Mixture Metropolis
  • Affine-Invariant Ensemble Sampler
  • Automated Factor Slice Sampler
  • Componentwise Hit-And-Run Metropolis
  • Delayed Rejection Adaptive Metropolis
  • Delayed Rejection Metropolis
  • Differential Evolution Markov Chain
  • Elliptical Slice Sampler
  • Equi-Energy Sampler
  • Gibbs Sampler
  • Griddy-Gibbs
  • Hamiltonian Monte Carlo
  • Hamiltonian Monte Carlo with Dual-Averaging
  • Hessian-Hamiltonian Monte Carlo
  • Hit-And-Run Metropolis
  • Independence Metropolis
  • Interchain Adaptation
  • Metropolis-Adjusted Langevin Algorithm
  • Metropolis-Coupled Markov Chain Monte Carlo
  • Metropolis-Hastings 1953
  • Metropolis-within-Gibbs
  • Multiple-Try Metropolis
  • No-U-Turn Sampler
  • Oblique Hyperrectangle Slice Sampler
  • Preconditioned Crank-Nicolson
  • Random Dive Metropolis-Hastings
  • Random-Walk Metropolis
  • Reflective Slice Sampler
  • Refractive Sampler
  • Reversible-Jump
  • Riemannian Manifold Hamiltonian Monte Carlo
  • Riemannian Manifold Metropolis Adjusted Langevin Algorithm
  • Robust Adaptive Metropolis
  • Sequential Adaptive Metropolis-within-Gibbs
  • Sequential Metropois-within-Gibbs
  • Slice Sampler
  • Stochastic Gradient Fisher Scoring
  • Stochastic Gradient Langevin Dynamics
  • Stochastic Gradient Nose-Hoover Thermostat
  • T-Walk
  • Tempered Hamiltonian Monte Carlo
  • Univariate Eigenvector Slice Sampler
  • Updating Sequential Adaptive Metropolis-within-Gibbs
  • Updating Sequential Metropolis-within-Gibbs

The following list contains stochastic Variational Inference (VI) samplers.

  • Black Box Sampler
  • Doubly Stochastic Sampler
  • Nonparametric Sampler
  • Particle Mirror Descent Sampler
  • Stein Variational Gradient Descent

Future Work

  • More samplers.
  • Quasi-random number generators (van der Corput-Halton sequence, Faure-Niederreiter sequence, Hammersley set, Poisson disk sampling, Sobol low-discrepancy sequence, ...).

Acknowledgements

Several samplers in this library are inspired by Keith O'Hara's library with the same name.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.