Statistical Rethinking Ch 3 Q1 Code / observed = data errors / beginner question

If you look carefully at the code in the notebook you linked, they use a Bernoulli distribution, whereas you are using a binomial distribution.

So you’re asking a different question than the one in the example, and the data take on a different interpretation. A Bernoulli distribution gives the probability of observing a success for a single experiment, like flipping a coin. Given this question and your data, it looks like the probability is something like 2/3 (6 successes and 9 trials).

With a binomial, the data are now the number of successes, out of n trials. You are saying, “each of these data are the number of successes out of n trials, what is the probability of success for a single flip?” Given this question, looking at your data, it’s something just below 10%, which the model correctly finds. In this setting, the data are 0/9, 0/9, 0/9, 1/9, 1/9, 1/9, 1/9, 1/9, 1/9.

So change the distribution and you’ll get the same answer as the notebook, but also realize that likelihood functions are ways to ask your data different kinds of questions!

3 Likes