A lightweight Bayesian sampling package
Project description
A Python package collecting awesome MCMC sampling algorithms.
Explore the docs »
Examples
|
Report Bug
|
Request Feature
Table of Contents
Features
- Lightweight Python library for sampling distributions in high dimensions using cutting-edge algorithms.
- Easily to use and simple to extend with new methods and use cases.
Examples
Quickstart example
We will sample points from the one-dimensional distribution using the random walk Metropolis algorithm, and then plot the results.
# Import racecar and numpy
import racecar as rc
import numpy as np
# Define the log likelihood function
def llh(x):
return {
'llh' : -( np.cos(2*x) + x**2/12 )
}
# Create the sampler object and use Random Walk Metropolis
initial_condition = [0]
learning_rate = 0.5
S = rc.sampler(initial_condition, learning_rate, llh, algo="RWMetropolis")
# Sample some points, outputting arrays of position and log likelihood
Pos_traj, LLH_traj = S.sample(100000, output=['pos','llh'])
# Plot the results using matplotlib
More examples
Some more detailed examples are given in detailed Jupyter notebooks below
- Example 1
- Example 2
- Example 3
Installation
You can install the package from source by cloning this repo and using setup.py
, the only dependencies are on numpy
and scipy
. Otherwise it is available on pip via
pip install racecar
License
Distributed under the MIT License. See LICENSE
for more information.
Contact
Made by Charles Matthews - www.cmatthe.ws - mail@cmatthe.ws
Project Link: https://github.com/c-matthews/racecar
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.