Bite Size Bayes: An Introduction to Probability and Bayesian Statistics in Python#
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:
The Linda problem: probability, conjunction and conditional probability, using data from the General Social Survey. Exercises on Colab
Bayes’s theorem: three theorems that follow from the definitions, ending with Bayes’s theorem. Exercises on Colab
The cookie problem: a first Bayesian update, and the Bayes table. Exercises on Colab
The dice problem: more than two hypotheses, and why the Bayes table works. Exercises on Colab
Medical tests: interpreting a positive test result, and the Elvis problem. Exercises on Colab
Probability mass functions: the 101 Bowls problem and the dice problem, with PMFs. Exercises on Colab
The Euro problem: estimating the probability that a coin lands heads; summarizing the posterior with credible intervals. Exercises on Colab
The World Cup problem: goal-scoring rates and the Poisson distribution. Exercises on Colab
Prediction: using posterior distributions to predict the outcome of a rematch. Exercises on Colab
Joint distributions: cross tabulation, and joint, conditional and marginal distributions. Exercises on Colab
Comparisons: a Bayesian update with two unknown quantities, the heights of two people. Exercises on Colab
The binomial distribution: the Euro problem revisited, and Bayes factors. Exercises on Colab
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.
The Bayesian bandit: Thompson sampling. Exercises on Colab
The GPS problem: inferring a position in two dimensions.
The flea beetle problem: classifying beetles by their measurements.
The Elvis problem: was Elvis an identical twin?
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.