https://github.com/davidbrochart/mcmc
MCMC samplers: Metropolis-Hastings and Sequential Monte Carlo
https://github.com/davidbrochart/mcmc
Last synced: 7 months ago
JSON representation
MCMC samplers: Metropolis-Hastings and Sequential Monte Carlo
- Host: GitHub
- URL: https://github.com/davidbrochart/mcmc
- Owner: davidbrochart
- Created: 2017-09-16T17:11:07.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-07-24T15:52:38.000Z (over 6 years ago)
- Last Synced: 2025-05-04T17:41:30.473Z (9 months ago)
- Language: Python
- Homepage:
- Size: 138 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This is a simple implementation of Markov Chain Monte Carlo samplers. Two
algorithms are currently provided. They are mostly stolen from
[PyMC3](https://github.com/pymc-devs/pymc3).
- **Metropolis-Hastings**
```python
import mcmc
# just provide initial values (q0) and a function returning the log-probability
# (logp)
sampler = mcmc.sampler(q0, logp)
samples = sampler.sample(1000)
```

- **Sequential Monte Carlo**
```python
import smc
# just provide the prior PDF (x), the likelihood log-probability, and the prior
# log-probability
samples = smc(x, likelihood_logp, prior_logp)
```
# Install
`pip install git+https://github.com/davidbrochart/mcmc`
or clone this repository and `pip install -e mcmc`.