Skip to main content

A lightweight Bayesian sampling package

Project description


Logo

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

Examples | Report Bug | Request Feature


Table of Contents

Why use Racecar?

  • Racecar is a lightweight Python library for sampling distributions in high dimensions using cutting-edge algorithms. It can also be used for rapid prototyping of novel methods and application to large problems.
  • Pass a function evaluating the log posterior and/or its gradient, and away you go. Ideal for usage with big data applications, neural networks, regression, mixture modelling, and all sorts of Bayesian inference and sampling problems.
  • Easily to use and simple to extend with new methods and use cases.
  • Designed for use with stochastic gradients in mind.

Results from an inference experiment

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 target log posterior function
# Note we only need it up to a constant multiple, so we do not need to
# know its normalization constant.
def log_posterior(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, log_posterior, algo="RWMetropolis")

# Sample some points, outputting arrays of the position and the log posterior
number_of_points = 100000
Pos_traj, LLH_traj = S.sample(number_of_points, output=['pos','llh'])

# Plot the results using matplotlib

Results

More examples

Some more detailed examples are given in the Jupyter notebooks below

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.10.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

racecar-0.0.10-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file racecar-0.0.10.tar.gz.

File metadata

  • Download URL: racecar-0.0.10.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5

File hashes

Hashes for racecar-0.0.10.tar.gz
Algorithm Hash digest
SHA256 ce59dfa120360851c5be7ebba48899f8d8690f7912101b0f39af984352c1489d
MD5 4770f3775ce7e4c61f96ceea7b560b51
BLAKE2b-256 af511f4306e718e54f9a1ee9b2f0f553bdfc79997b9adbea86d056bc290ce13c

See more details on using hashes here.

File details

Details for the file racecar-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: racecar-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5

File hashes

Hashes for racecar-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 afb93ccc1c03b61d3143e2b8eb2973dff5e6499767b1f4cc2430a2073f8516f9
MD5 dfd16e5519bca470a51e2341b1d91db0
BLAKE2b-256 ef385744443e62eab4c17638acfcbc41030a3bab3b0a7a1a58136d02b728ad79

See more details on using hashes here.

Supported by

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