# Think Bayes Book - The M&M Problem - How is Normalizing constant calculated?

In his book this problem is given for M&M's as an example of Bayes.

The M&M problem M&M’s are small candy-coated chocolates that come in a variety of colors. Mars, Inc., which makes M&M’s, changes the mixture of colors from time to time. In 1995, they introduced blue M&M’s. Before then, the color mix in a bag of plain M&M’s was 30% Brown, 20% Yellow, 20% Red, 10% Green, 10% Orange, 10% Tan. Afterward it was 24% Blue , 20% Green, 16% Orange, 14% Yellow, 13% Red, 13% Brown. Suppose a friend of mine has two bags of M&M’s, and he tells me that one is from 1994 and one from 1996. He won’t tell me which is which, but he gives me one M&M from each bag. One is yellow and one is green. What is the probability that the yellow one came from the 1994 bag? This problem is similar to the cookie problem, with the twist that I draw one sample from each bowl/bag. This problem also gives me a chance to demonstrate the table method, which is useful for solving problems like this on paper. In the next chapter we will solve them computationally. The first step is to enumerate the hypotheses. The bag the yellow M&M came from I’ll call Bag 1; I’ll call the other Bag 2. So the hypotheses are: • A: Bag 1 is from 1994, which implies that Bag 2 is from 1996. • B: Bag 1 is from 1996 and Bag 2 from 1994. Now we construct a table with a row for each hypothesis and a column for each term in Bayes’s theorem: Prior Likelihood Posterior The first column has the priors. Based on the statement of the problem, it is reasonable to choose p A =p B =1 / 2. The second column has the likelihoods, which follow from the information in the problem. For example, if A is true, the yellow M&M came from the 1994 bag with probability 20%, and the green came from the 1996 bag with probability 20%. Because the selections are independent, we get the conjoint probability by multiplying. The third column is just the product of the previous two. The sum of this column, 270, is the normalizing constant. To get the last column, which contains the posteriors, we divide the third column by the normalizing constant. That’s it. Simple, right? Well, you might be bothered by one detail. I write p D H in terms of percentages, not probabilities, which means it is off by a factor of 10,000. But that cancels out when we divide through by the normalizing constant, so it doesn’t affect the result. When the set of hypotheses is mutually exclusive and collectively exhaustive, you can multiply the likelihoods by any factor, if it is convenient, as long as you apply the same factor to the entire column.

Now I am totally fine until we get to the normalizing constant.

p(H) p(D|H)


How are the numbers 200 and 70 derived? Then he goes on to state that

I write p D H in terms of percentages, not probabilities, which means it is off by a factor of 10,000. But that cancels out when we divide through by the normalizing constant, so it doesn’t affect the result

How do I calculate this 10,000 error?

You are right to be confused, as this author has chosen an absolutely idiotic way of expressing things! He or she has expressed probabilites as percentages, but the percent sign literally means "divide by 100", so for example, if you are multiplying $20\%$ by $20\%$, it means

$$\frac{20}{100} \times \frac{20}{100} = \frac{20 \times 20}{100 \times 100} = \frac{400}{10000}$$

The author has chosen to do this in two steps: first, do $20 \times 20$ and then "correct" the result by dividing by $10000$.

The numbers $200$ and $70$ in the table are just obtained by multiplying the first and second columns, so $\frac{1}{2} \times 20 \times 20 = 200$ and $\frac{1}{2} \times 10 \times 14 = 70$. These numbers should actually be $\frac{1}{2} \times \frac{20}{100} \times \frac{20}{100} = \frac{200}{10000}$ and $\frac{1}{2} \times \frac{10}{100} \times \frac{14}{100} = \frac{70}{10000}$. When you add them and then divide one by the other, the $10000$'s cancel out, which is what the author means by a "noramlizing constant".

The first row of the table should be written like this, without the confusing percentages. (As written in the book, it's actually incorrect anyway because the $\%$ signs have been omitted.)

$$0.5 | 0.2 \times 0.2 | 0.02 | 20/27$$

and similarly for the second row. I would advise you to find a better book!

• Thank you for the clarification I really couldn't get your explanation is great. – sayth Jun 21 '16 at 2:28