Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mauro3/KissMCMC.jl
Keep it simple, stupid, MCMC
https://github.com/mauro3/KissMCMC.jl
emcee mcmc-sampler
Last synced: 3 months ago
JSON representation
Keep it simple, stupid, MCMC
- Host: GitHub
- URL: https://github.com/mauro3/KissMCMC.jl
- Owner: mauro3
- License: other
- Created: 2016-07-12T14:18:19.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-04-13T13:52:22.000Z (over 2 years ago)
- Last Synced: 2024-07-10T05:17:34.789Z (4 months ago)
- Topics: emcee, mcmc-sampler
- Language: Julia
- Size: 4.84 MB
- Stars: 14
- Watchers: 4
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-sciml - mauro3/KissMCMC.jl: Keep it simple, stupid, MCMC
README
# KissMCMC
[![Build Status](https://github.com/mauro3/KissMCMC.jl/workflows/CI/badge.svg)](https://github.com/mauro3/KissMCMC.jl/actions)
[![Build Status](https://ci.appveyor.com/api/projects/status/github/mauro3/KissMCMC.jl?svg=true)](https://ci.appveyor.com/project/mauro3/KissMCMC-jl)
[![Coverage](https://codecov.io/gh/mauro3/KissMCMC.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/mauro3/KissMCMC.jl)Got a probability density function you want to draw samples from?
Don't want to learn all the fancy stuff of the fancy sampler packages?
The KissMCMC (Keep it simple, stupid, MCMC) package intends to provide
a few simple MCMC samplers.```julia
using KissMCMC
# the distribution to sample from,
logpdf(x::T) where {T} = x<0 ? -convert(T,Inf) : -x
# initial point of walker
theta0 = 0.5# Metropolis MCMC sampler:
sample_prop_normal(theta) = 1.5*randn() + theta # samples the proposal (or jump) distribution
thetas, accept_ratio = metropolis(logpdf, sample_prop_normal, theta0, niter=10^5)
println("Accept ratio Metropolis: $accept_ratio")# emcee MCMC sampler:
thetase, accept_ratioe = emcee(logpdf, make_theta0s(theta0, 0.1, logpdf, 100), niter=10^5)
# check convergence using integrated autocorrelation
thetase, accept_ratioe = squash_walkers(thetase, accept_ratioe) # puts all walkers into one
println("Accept ratio emcee: $accept_ratio")using Plots
histogram(thetas, normalize=true, fillalpha=0.4)
histogram!(thetase, normalize=true, fillalpha=0.1)
plot!(0:0.01:5, map(x->exp(logpdf(x)[1]), 0:0.01:5), lw=3)
```
outputs:![](https://cloud.githubusercontent.com/assets/4098145/16770344/dcb4a47a-484c-11e6-8f6e-0c2d223e9443.png)
MCMC samplers:
- Metropolis (serial) `metropolis`
- Affine invariant MCMC, aka emcee `emcee` (threaded)# References
Other, probably better Julia MCMC packages:
- https://github.com/tpapp/DynamicHMC.jl
- https://github.com/madsjulia/AffineInvariantMCMC.jl
- https://github.com/brian-j-smith/Mamba.jl
- and many othersThe (original) emcee python package: https://github.com/dfm/emcee