urn type problem with bayes theorem (and M&Ms) don't understand how probability of seeing 'evidence' was calculated.

I was trying to follow the solution to the 'urn type' probability problem with M&M's from this page -> http://allendowney.blogspot.com/2011/10/all-your-bayes-are-belong-to-us.html

I have reproduced the problem below, but what I don't get is the skipped steps after he says

Plugging the likelihoods and the priors into Bayes's theorem, we get P(A|E) = 40 / 54 ~ 0.74 "

I understand the formula:

P(E) P(A|E) =  P(A) P(E|A)

=>

P(A|E) = P(A) P(E|A)
-----------
P(E)


And I got this far:

P(A) = .5
P(E|A) = .2 * .2

P(A|E) =  (.5)  (.2) (.2)
-----------
P(E)


But I am stuck on how the author of the post calculated P(E)
(the probability of the evidence). Any guidance much appreciated !

M&M Problem

The blue M&M was introduced in 1995. Before then, the color mix in a bag of plain M&Ms 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).

A friend of mine has two bags of M&Ms, 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 M&M came from the 1994 bag?

Hypotheses:

A: Bag #1 from 1994 and Bag #2 from 1996

B: Bag #2 from 1994 and Bag #1 from 1996

Again, P(A) = P(B) = 1/2.

The evidence is: E: yellow from Bag #1, green from Bag #2

We get the likelihoods by multiplying the probabilities for the two M&M:

P(E|A) = (0.2)(0.2) P(E|B) = (0.1)(0.14)

For example, P(E|B) is the probability of a yellow M&M in 1996 (0.14) times the probability of a green M&M in 1994 (0.1).

Plugging the likelihoods and the priors into Bayes's theorem, we get P(A|E) = 40 / 54 ~ 0.74

• I think he got that wrong that bag 1 and bag 2 were picked! What he did pick is a sweet from the 1994 bag and a sweet from the 1996 bag, there was then a result of a yellow and green sweet - you can work the prob of that result out, just add together the two exclusive ways it can happen - you can also see the prob of yellow coming from 1994 is .2 and green from 1996 is .2 – Cato Sep 13 '16 at 9:21

Notice that: \begin{align*} \Pr[E] &= \Pr[E \text{ and } (A \text{ or } B)] &\text{since $A$ and $B$ are the only two possibilities}\\ &= \Pr[(E \text{ and } A) \text{ or } (E \text{ and }B)] \\ &= \Pr[E \text{ and } A] + \Pr[E\text{ and }B] &\text{since $A$ and $B$ are mutually exclusive}\\ &= \Pr[A]\Pr[E \mid A] + \Pr[B]\Pr[E \mid B] \\ &= \frac{1}{2}(0.2)(0.2) + \frac{1}{2}(0.14)(0.1) \\ &= 0.027 \end{align*}

• I don't see why the half, the order he picks the sweets from the bags is irrelevant, he DOES pick a sweet from 1994 bag with probability 1, and there is a .2% chance that it is yellow, in which case there is then a .2% chance he will go on and make yellow-green. Similar applies for making green-yellow (which is the same result to the observer (.14 x .1) – Cato Sep 13 '16 at 9:16
• Thanks, Adirano... nice trick with Pr[E] = Pr[E and (A or B)] -- worth remembering ! – Chris Bedford Sep 13 '16 at 22:53

A = given yellow M & M from 1994 bag B = given yellow and green M & M

P(A) = .2

P(A and B) = .2 x .2 = .04
the above is to say, that a Yellow comes from A, with probability .2 AND the other (now necessarily from B) is Blue, with probability 0.2

for B to be true, Green was taken from either 1994 or 1996

P(B) = P(yellow from 1994)P(green from 1996) + P(green from 1994)P(yellow from 1996) = .2 x .2 + .1 x .14 = .04 + .014 = .054

P(A | B) = P(A and B) / P(B) = .04 / .054 = 0.74074

..................................................

I don't really agree with his hypothesis about bag A and bag B with probability 1/2, that isn't necessary, it is very confusing