So there is a 74% chance that the yellow comes from the 1994 bag.

Answering this question was straightforward: just like all the other probability problems, we simply create a sample space, and use P to pick out the probability of the event in question, given what we know about the outcome. But in a sense it is curious that we were able to solve this problem with the same methodology as the others: this problem comes from a section titled My favorite Bayes's Theorem Problems, so one would expect that we'd need to invoke Bayes Theorem to solve it. The computation above shows that that is not necessary.

Of course, we could solve it using Bayes Theorem. Why is Bayes Theorem recommended? Because we are asked about the probability of an event given the evidence, which is not immediately available; however the probability of the evidence given the event is.

Before we see the colors of the M&Ms, there are two hypotheses, A and B , both with equal probability:

A: first M&M from 94 bag, second from 96 bag B: first M&M from 96 bag, second from 94 bag P(A) = P(B) = 0.5

Then we get some evidence:

E: first M&M yellow, second green

We want to know the probability of hypothesis A , given the evidence:

P(A | E)

That's not easy to calculate (except by enumerating the sample space). But Bayes Theorem says:

P(A | E) = P(E | A) * P(A) / P(E)

The quantities on the right-hand-side are easier to calculate:

P(E | A) = 0.20 * 0.20 = 0.04 P(E | B) = 0.10 * 0.14 = 0.014 P(A) = 0.5 P(B) = 0.5 P(E) = P(E | A) * P(A) + P(E | B) * P(B) = 0.04 * 0.5 + 0.014 * 0.5 = 0.027

And we can get a final answer:

P(A | E) = P(E | A) * P(A) / P(E) = 0.04 * 0.5 / 0.027 = 0.7407407407

You have a choice: Bayes Theorem allows you to do less calculation at the cost of more algebra; that is a great trade-off if you are working with pencil and paper. Enumerating the state space allows you to do less algebra at the cost of more calculation; often a good trade-off if you have a computer. But regardless of the approach you use, it is important to understand Bayes theorem and how it works.

There is one important question that Allen Downey does not address: would you eat twenty-year-old M&Ms? 😨