Welcome to the online version Bayesian Modeling and Computation in Python. If you’d like a physical copy it can purchased from the publisher here or on Amazon.


This site contains an online version of the book and all the code used to produce the book. This includes the visible code, and all code used to generate figures, tables, etc.

Updated code

For the most up-to-date code please check the folder notebooks_updated. This code is updated to work with the latest versions of the libraries used in the book, which means that some of the code will be different from the one in the book.


If you use the online or printed versions of this book in your own work, please cite us using

Martin Osvaldo A, Kumar Ravin; Lao Junpeng Bayesian Modeling and Computation in Python Boca Ratón, 2021. ISBN 978-0-367-89436-8

Here is the citation in BibTeX format

  title = {{Bayesian Modeling and Computation in Python}},
  author = {Martin, Osvaldo A. and Kumar, Ravin and Lao, Junpeng},
  year = {2021},
  month = dec,
  address = {{Boca Raton}},
  isbn = {978-0-367-89436-8},

See a mistake?#

File an issue if you notice anything broken so we can fix it.

Environment installation#

To run the code you will need to install the correct packages in a computational environment. We have provided instructions below for common options.


conda env create -f environment.yml
conda activate bmcp


The book code can also be run using Google Colab. https://colab.research.google.com


This book is only possible because open source contributors working on the projects we used. If you like this book we encourage you to make a donation to ArviZ or PyMC.



This book is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License, except for the code (including the code blocks and jupyter notebooks) which are licensed under the GNU GENERAL PUBLIC LICENSE Version 2.