Git Product home page Git Product logo

affineinvariantmcmc.jl's Introduction

AffineInvariantMCMC

AffineInvariantMCMC performs Bayesian sampling using Goodman & Weare's Affine Invariant Markov Chain Monte Carlo (MCMC) Ensemble sampler. AffineInvariantMCMC is a module of MADS. Goodman & Weare's algorithm implementation in Python is called Emcee.

Coverage Status

Reference:

Goodman, Jonathan, and Jonathan Weare. "Ensemble samplers with affine invariance." Communications in applied mathematics and computational science 5.1 (2010): 65-80. Link

Installation

import Pkg; Pkg.add("AffineInvariantMCMC")

Example

import AffineInvariantMCMC

numdims = 5
numwalkers = 100
thinning = 10
numsamples_perwalker = 1000
burnin = 100

const stds = exp(5 * randn(numdims))
const means = 1 + 5 * rand(numdims)
llhood = x->begin
	retval = 0.
	for i = eachindex(x)
		retval -= .5 * ((x[i] - means[i]) / stds[i]) ^ 2
	end
	return retval
end
x0 = rand(numdims, numwalkers) * 10 - 5
chain, llhoodvals = AffineInvariantMCMC.sample(llhood, numwalkers, x0, burnin, 1)
chain, llhoodvals = AffineInvariantMCMC.sample(llhood, numwalkers, chain[:, :, end], numsamples_perwalker, thinning)
flatchain, flatllhoodvals = AffineInvariantMCMC.flattenmcmcarray(chain, llhoodvals)

Comparison

The figures below compare predicted marginal and joint posterior PDF's (probability density functions) using Classical vs. Affine Invariant MCMC for the same number of functional evaluations (in this case 1,000,000).

The synthetic problem tested below is designed to have a very complex structure. The Classical MCMC clearly fails to characterize sufficiently well the posterior PDF's.

  • Classical MCMC ClassicalMCMC
  • Affine Invariant MCMC AffineInvariantMCMC

The codes applied to perform these analyses are available here:

Parallelization

AffineInvariantMCMC can be executed efficiently in parallel using existing distributed network capabilities.

For more information, check out our Julia module RobustPmap.

Restarts

AffineInvariantMCMC analyses can be performed utilizing extremely efficient restarts.

Typically, the AffineInvariantMCMC runs require a large number of functional (model) evaluations which may take substantial computational time. Occasionally, the AffineInvariantMCMC runs may crash due to external issues (e.g., network/computer/disk failures). Furthermore, AffineInvariantMCMC runs may require more time than the allowed allocation time on existing HPC cluster queues. In all these cases, the AffineInvariantMCMC runs need to be restarted. Our codes allow for efficient restarts with very minimal overhead and without re-execution of completed functional (model) evaluations.

For more information, check out our Julia module ReusableFunctions.

Documentation

All the available MADS modules and functions are described at madsjulia.github.io

AffineInvariantMCMC functions are documented at https://madsjulia.github.io/Mads.jl/Modules/AffineInvariantMCMC

Projects using AffineInvariantMCMC

Projects using AffineInvariantMCMC

Publications, Presentations, Projects

affineinvariantmcmc.jl's People

Contributors

montyvesselinov avatar omalled avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

affineinvariantmcmc.jl's Issues

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Measuring and adjusting the acceptance rate

It would be useful to add an acceptance rate to the sampler to see whether the a parameter should be adjusted.

If the acceptance rate is too small, I would adjust the a parameter closer to unity automatically via:

a_{new} = 1 + (a_{old} -1)*(acc_{measured}/acc_{target})

where acc_{measured} is the measured value of acceptance (over some number of steps), while acc_{target} is a target acceptance rate (usually 25%). Then, once the target acceptance rate is reached, the value of a stays constant.

Pass parameters to llhood function?

Good day,

Thank you so much for making this library.

I am relatively new to Julia in general and trying to port over an MCMC tool I wrote in python with emcee. I have successfully gotten it working with your library (and it's loads faster - which was my purpose for porting, so quite happy!)

I need to pass additional arguments to my llhood function outside of the vector with the parameters. (I have a bunch of details that are required to run the function, that do not change during sampling.) In emcee this is trivial (you can pass an args argument, ie:

sampler = emcee.EnsembleSampler(nwalkers, ndim, logpost, args=[case]) 

) but I do not see how to do that in this library. (For testing, I just hard coded the details in the function...)

I tried modifying the sample function to pass more to the rpmap call, I made a bit of progress but it was too complicated for me.

Is there an obvious way I'm missing here? Or any other suggestions?

Thank you!

Parallel MCMC

I like how easy it is to sample in parallel with the emcee python package (just set the threads keyword to >1). Do you have any plans to implement this in a similar fashion?

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.