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

Why are we subtracting 1 from each bowl (Chapter 2 Exercise: cookie problem) #28

Open akshat1995-sc opened 4 years ago

akshat1995-sc commented 4 years ago

In the likelihood function, the data (i.e. the cookie flavor) is being subtracted from both bowl 1 and bowl 2 to obtain the new bowl/pmf data. I thought that after the first draw, there would be two scenarios. 1). The cookie was drawn from bowl 1, in which case, the data would only be subtracted from bowl 1 values. 2). The cookie was drawn from bowl 2, in which case, the data would only be subtracted from bowl 2 values.

Theses instances would then result in two different pmf data right? 1). Hist({'vanilla': 29, 'chocolate': 10}) Hist({'vanilla': 20, 'chocolate': 20})

2). Hist({'vanilla': 30, 'chocolate': 10}) Hist({'vanilla': 19, 'chocolate': 20})

AllenDowney commented 4 years ago

Which file are you looking at?

akshat1995-sc commented 4 years ago

I am looking at 'cookie_soln.ipynb' in solutions folder.

akshat1995-sc commented 4 years ago

IMG_20200712_150712

akshat1995-sc commented 4 years ago

What I mean to state is that, there would be four different outcomes in the 2nd draw. P(B1 | Choc, A_1), P(B2 | Choc, A_1), P(B1 | Choc, B_2), P(B2 | Choc, B_2). with the notations as follows: A: Vanilla draw from bowl 1 B: Vanilla draw from bowl 2 A_1 : Event A in draw no.1 A_2 : Event A in draw no. 2 B1: current draw from bowl 1 B2: current draw from bowl 2

Is it clearer?

AllenDowney commented 4 years ago

Yes, I see why this is confusing, but I think the solution is correct.

The first Hist represents the hypothesis that we are drawing from Bowl 1. The second represents the hypothesis that we are drawing from Bowl 2.

When we draw the first cookie, we compute the likelihood of the data based on the old proportions. And then we update the proportions.

When we draw the second cookie, we want to compute

P(data | both cookies are from Bowl 1)

and

P(data | both cookies are from Bowl 2)

So in both cases we should use the update proportions.

You are right that in the first scenario, Bowl 2 is unchanged.

And in the second scenario, Bowl 1 is unchanged.

But since we never refer to the proportions in the unused bowl, I didn't bother to represent it.

What do you think? Allen

On Sun, Jul 12, 2020, at 9:10 AM, A.Srivastava wrote:

IMG_20200712_150712 https://user-images.githubusercontent.com/41738944/87247064-ac47c080-c451-11ea-886e-7059fcf03f77.jpg

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/AllenDowney/ThinkBayes2/issues/28#issuecomment-657219860, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOLP3KFNDHTLD732RBLJULR3GY2VANCNFSM4OXLQ4WQ.

akshat1995-sc commented 4 years ago

I attempted to evaluate the following values using the aforementioned table (i.e the updated content of bowls) in picture above. P(data | both cookies are from Bowl 1), and P(data | both cookies are from Bowl 2)

The result is quite different from the ones obtained in 'cookie_soln.ipynb'. Please check the image. Do you think I am missing something? IMG_20200713_090514

akshat1995-sc commented 4 years ago

Was the above solution confusing? I simply attempted to extend the suggested probabilities on paper.