AllenDowney / ThinkBayes2

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

Is the solution for cookie problem without replacement (cookie3.py) incomplete? #10

Closed luxspes closed 6 years ago

luxspes commented 6 years ago

Hi!

First, let me thank you for creating all this, it is really a nice resource for developers like me to learn how to solve problems with bayesian methods. Now the my question: I was surprised by the output of the code on cookie3.py. Am I right to think the code in that file is an incomplete solution to the "cookie problem without replacement"? If it were a complete solution I would have expected the code to construct a growing set of hypothesis as cookies go away, to consider the scenarios in which the cookie removal could be evening out between the bowls, which the current code is not doing.

Say for example, that you eat 21 vanilla cookies ( no replacement ;-) )

    for x in range(0, 21):
         suite.Update('vanilla')

Then the cookie3.py will printout:

Hist({'vanilla': 9, 'chocolate': 10}) 1.0 Hist({'vanilla': 0, 'chocolate': 20}) 0.0

Reaching the conclusion that there in no chance (0.0) the 21th cookie came from bowl2, when it could have been the case that 10 of those cookies came from "bow1" and 11 from "bowl2" making the probability of getting a 21th vanilla cookie from bowl2 non zero. Or maybe I missed some simplifying assumption in the text of the book?

Thanks

luxspes commented 6 years ago

Nevermind, I see it now, the simplifying assumption is that all cookies come from the same bag the first came from

AllenDowney commented 6 years ago

Thanks for the update. Glad you resolved it.

On Sun, Jul 1, 2018 at 1:29 PM, LuxSpes notifications@github.com wrote:

Nevermind, I see i now, the simplifying assumption is that all cookies come from the same bag the first came from

— 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/10#issuecomment-401620832, or mute the thread https://github.com/notifications/unsubscribe-auth/ABy37fC6JwApBPhszeSAWuUTtAsHZ9KFks5uCQcDgaJpZM4U-Ol8 .