Monad-Bayes

A library for probabilistic programming in Haskell.

See the docs for a user guide, notebook-style tutorials, an example gallery, and a detailed account of the implementation.

Created by Adam Scibior (@adscib), documentation, website and newer features by Reuben, maintained by Tweag.

Project status

Now that monad-bayes has been released on Hackage, and the documentation and the API has been updated, we will focus on adding new features. See the Github issues to get a sense of what is being prepared, and please feel free to make requests.

Background

The basis for the code in this repository is the ICFP 2018 paper [2]. For the code associated with the Haskell2015 paper [1], see the haskell2015 tag.

[1] Adam M. Ścibior, Zoubin Ghahramani, and Andrew D. Gordon. 2015. Practical probabilistic programming with monads. In Proceedings of the 2015 ACM SIGPLAN Symposium on Haskell (Haskell ’15), Association for Computing Machinery, Vancouver, BC, Canada, 165–176.

[2] Adam M. Ścibior, Ohad Kammar, and Zoubin Ghahramani. 2018. Functional programming for modular Bayesian inference. In Proceedings of the ACM on Programming Languages Volume 2, ICFP (July 2018), 83:1–83:29.

[3] Adam M. Ścibior. 2019. Formally justified and modular Bayesian inference for probabilistic programs. Thesis. University of Cambridge.

Hacking

  1. Install stack by following these instructions.

  2. Clone the repository using one of these URLs:

    git clone [email protected]:tweag/monad-bayes.git
    git clone https://github.com/tweag/monad-bayes.git
    

Now you can use stack build, stack test and stack ghci.

To view the notebooks, go to the website. To use the notebooks interactively:

  1. Compile the source: stack build
  2. If you do not have nix install it.
  3. Run nix develop --system x86_64-darwin --extra-experimental-features nix-command --extra-experimental-features flakes - this should open a nix shell. For Linux use x86_64-linux for --system option instead.
  4. Run jupyter-lab from the nix shell to load the notebooks.

Your mileage may vary.

Changes

1.3.0.3

  • Relaxed some version bounds

1.3.0.2

  • Relaxed some version bounds

1.3.0.1

  • Support for GHC 9.8

1.3.0

1.2.0

1.1.1

  • add fixture tests for benchmark models
  • extensive documentation improvements
  • add poissonPdf
  • Fix TUI inference
  • Fix flaky test
  • Support GHC 9.4

1.1.0

  • extensive notebook improvements

1.0.0 (2022-09-10)

  • host website from repo
  • host notebooks from repo
  • use histogram-fill

0.2.0 (2022-07-26)

  • rename various functions to match the names of the corresponding types (e.g. Enumerator goes with enumerator)
  • add configs as arguments to inference methods smc and mcmc
  • add rudimentary tests for all inference methods
  • put mcmc as inference method in new module Control.Monad.Bayes.Inference.MCMC
  • update history of changelog in line with semantic versioning conventions
  • bumped to GHC 9.2.3

0.1.5 (2022-07-26)

  • Refactor of sampler to be parametric in the choice of a pair of IO monad and RNG

0.1.4 (2022-06-15)

Addition of new helper functions, plotting tools, tests, and Integrator monad.

  • helpers include: toEmpirical (list of samples to empirical distribution) and toBins (simple histogramming)
  • Integrator is an instance of MonadDistribution for numerical integration
  • notebooks now contains working notebook-based tutorials and examples
  • new tests, including with conjugate distributions to compare analytic solution against inferred posterior
  • models directory is cleaned up. New sequential models using pipes package to represent monadic streams

0.1.3 (2022-06-08)

Clean up of unused functions and broken code

  • remove unused functions in Weighted and Population
  • remove broken models in models
  • explicit imports
  • added some global language extensions

0.1.2 (2022-06-08)

Add documentation

  • docs written in markdown
  • docs built by sphinx

0.1.1 (2020-04-08)

  • New exported function: Control.Monad.Bayes.Class now exports discrete.

0.1.0 (2020-02-17)

Initial release.