Bayesian Statistics Made Simple: A Tutorial in Python

Bayesian Statistics Made Simple: A Tutorial in Python#

Allen Downey

Bayesian statistical methods are becoming more common, but there are not many resources to help beginners get started. People who know Python can use their programming skills to get a head start.

In this tutorial, I introduce Bayesian methods using grid algorithms, which help develop understanding and prepare for MCMC, which is a powerful algorithm for real-world problems.

It is based on my book, Think Bayes, and my blog, Probably Overthinking It.

Level: beginner. You should be comfortable with basic Python; some experience with NumPy and pandas helps. You don’t need any background in statistics.

Length: about 90 minutes.

The notebooks#

The pages on this site show the notebooks with solutions. To do the exercises, run the versions with blanks on Colab:

  1. The cookie problem: Bayes’s theorem as a table of priors, likelihoods and posteriors; then the 101 Bowls problem. Exercises on Colab

  2. The Euro problem: estimating the probability that a coin lands heads; uniform and triangle priors, the posterior mean, and credible intervals. Exercises on Colab

  3. The Bayesian bandit problem: updating beliefs about several slot machines, and using them to decide which one to play next. Exercises on Colab

Slides for this tutorial are here.

Recordings#

I presented this tutorial at PyCon US every year from 2012 to 2016 and at SciPy 2019. The most recent recording is from SciPy 2019. The code in the videos is an earlier version; the repository README lists the version that goes with each video.

Next steps#

To go further, read Think Bayes, which is free online, or see my other workshops.

The code is on GitHub, under the MIT License.