Skip to main content

A lightweight Bayesian sampling package

Project description


Logo

A Python package collecting awesome sampling algorithms.
Explore the docs »

Examples | Report Bug | Request Feature


Table of Contents

Examples

Simple example

We will sample points from the distribution using racecar and 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

Results

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.

Source Distribution

racecar-0.0.3.tar.gz (8.1 kB view hashes)

Uploaded Source

Built Distribution

racecar-0.0.3-py3-none-any.whl (10.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page