Bite Size Bayes: An Introduction to Probability and Bayesian Statistics in Python

Bite Size Bayes: An Introduction to Probability and Bayesian Statistics in Python#

Allen Downey

Bite Size Bayes is an introduction to probability and Bayesian statistics using Python. It starts from scratch, with no previous knowledge of probability or Bayesian methods, and works up to Bayesian estimation, prediction and decision analysis, in short notebooks you can run on Colab.

It uses only basic Python and pandas: each problem is solved with a Bayes table or a distribution stored in a pandas Series, so you can see every step of the computation.

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

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 Linda problem: probability, conjunction and conditional probability, using data from the General Social Survey. Exercises on Colab

  2. Bayes’s theorem: three theorems that follow from the definitions, ending with Bayes’s theorem. Exercises on Colab

  3. The cookie problem: a first Bayesian update, and the Bayes table. Exercises on Colab

  4. The dice problem: more than two hypotheses, and why the Bayes table works. Exercises on Colab

  5. Medical tests: interpreting a positive test result, and the Elvis problem. Exercises on Colab

  6. Probability mass functions: the 101 Bowls problem and the dice problem, with PMFs. Exercises on Colab

  7. The Euro problem: estimating the probability that a coin lands heads; summarizing the posterior with credible intervals. Exercises on Colab

  8. The World Cup problem: goal-scoring rates and the Poisson distribution. Exercises on Colab

  9. Prediction: using posterior distributions to predict the outcome of a rematch. Exercises on Colab

  10. Joint distributions: cross tabulation, and joint, conditional and marginal distributions. Exercises on Colab

  11. Comparisons: a Bayesian update with two unknown quantities, the heights of two people. Exercises on Colab

  12. The binomial distribution: the Euro problem revisited, and Bayes factors. Exercises on Colab

  13. The Price Is Right problem: kernel density estimation, and using the posterior distribution to choose the best bid. Exercises on Colab

More examples#

These notebooks are not part of the sequence, but they use the same methods.

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; the text is under the CC BY-NC-SA 4.0 license.