AllenDowney / ThinkBayes2

Text and code for the forthcoming second edition of Think Bayes, by Allen Downey.
http://allendowney.github.io/ThinkBayes2/
MIT License
1.8k stars 1.49k forks source link

M&M problem in chapter 2: Bayes' theoreom #44

Closed NaraMB closed 1 year ago

NaraMB commented 3 years ago

After thinking through and solving the problem successfully, I looked at solution. A subtle (and even trivial, may be) change in defining hypothesis and data could be

Hypotheses A: one M&M from 94, another from 96 Hypotheses B: one from 96, another from 94 Given: one is yellow and one is green

Here, formulation of hypothesis is based on the information in the problem. (one from each bag; it could be of any color) Data or Given is yellow from one and green from another, which changes the likelihood based on the color.

If we state hypothesis as "green from 1994 and yellow from 1996", it seems like hypothesis itself is defined based on the Data :). It took me a while to figure it out. Is my understanding correct here?

AllenDowney commented 3 years ago

The way you have stated those hypotheses, they are both true.

I agree that the way the hypotheses are stated in the book takes some work to untangle, but I think the solution is correct.

On Thu, Jul 1, 2021, at 3:27 AM, NaraMB wrote:

After thinking through and solving the problem successfully, I looked at solution. A subtle (and even trivial, may be) definition in hypothesis and data could be

Hypotheses A: one M&M from 94, another from 96

Hypotheses B: one from 96, another from 94

Given: one is yellow and one is green

Here, formulation of hypothesis is based on the information in the problem. (one from each bag; it could be of any color) Data or Given is yellow from one and green from another, which changes the likelihood based on the color.

If we state hypothesis as "green from 1994 and yellow from 1996", it seems like hypothesis itself is defined based on the Data :). It took me a while to figure it out. Is my understanding correct here?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/AllenDowney/ThinkBayes2/issues/44, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOLP3O5VJEFPQXR6LLMV73TVQKH5ANCNFSM47T4VWLA.

MassD commented 1 year ago

@NaraMB

I think there might be an easier-to-understand way for the hypotheses and data

Data: Got Y (yellow) and G (green), and each from one bag respectively.

Hypotheses: Y is from b94

Since the data already assumed one from each bag, we can ignore the cases where Y and G are from the same bag.

Here is the Bayes'

P(Y_{b94} | YG) = p(Y_{b94}) * P(YG | Y_{b94}) \over P(YG)

where

$P(Y_{b94}) = P(b94) * P(Y | b94) = {1 \over 2 }* 0.2$ (Theorem 2 on page 13)

$P(YG | Y_{b94}) = P (G_{b96}) = 0.2$, as since Y is already from b94, G must be from b96, thus 0.2

$P(YG) = P(Y_{b1994}) * P(YG | Y_{b1994}) + P(Y_{b1996}) * P(YG | Y_{b1996}) = {1 \over 2+1 }* 0.2 * 0.2 + {1 \over 2 }*0.14*0.1$