Chapter 3. Distributions

In the previous chapter we used Bayes’s theorem to solve a Cookie Problem; then we solved it again using a Bayes table. In this chapter, at the risk of testing your patience, we will solve it one more time using a Pmf object, which represents a “probability mass function”. I’ll explain what that means, and why it is useful for Bayesian statistics.

We’ll use Pmf objects to solve some more challenging problems and take one more step toward Bayesian statistics. But we’ll start with distributions.

Distributions

In statistics a distribution is a set of possible outcomes and their corresponding probabilities. For example, if you toss a coin, there are two possible outcomes with approximately equal probability. If you roll a 6-sided die, the set of possible outcomes is the numbers 1 to 6, and the probability associated with each outcome is 1/6.

To represent distributions, we’ll use a library called empiricaldist. An “empirical” distribution is based on data, as opposed to a theoretical distribution. We’ll use this library throughout the book. I’ll introduce the basic features in this chapter and we’ll see additional features later.

Probability Mass Functions

If the outcomes in a distribution are discrete, we can describe the distribution with a probability mass function, or PMF, which is a function that maps from each possible outcome to its probability.

empiricaldist provides a class called Pmf that represents a probability mass function. To use Pmf you can ...

Get Think Bayes, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.