Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

die_rolled error #2

Open
jbwhit opened this issue Jan 18, 2016 · 0 comments
Open

die_rolled error #2

jbwhit opened this issue Jan 18, 2016 · 0 comments

Comments

@jbwhit
Copy link

jbwhit commented Jan 18, 2016

I think that I've found a bug in the logic behind this bit:

die_rolled(9, hypotheses)
Out[323]:
{6: 0.0,
 8: 0.0,
 12: 0.72553987580240009,
 20: 0.15671661317331853,
 22: 0.11774351102428135}

You need to reset the hypotheses, because they are being overwritten each time you roll the die, so the correct answer should be:

hypotheses = {
    6: 1,
    8: 1,
    12:1,
    20:1,
    22:1
}

# Normalize
total_possibilities = sum(hypotheses.values())
for key, value in hypotheses.items():
    hypotheses[key] = hypotheses[key]/(1.0*total_possibilities)

die_rolled(9, hypotheses)

{6: 0.0,
 8: 0.0,
 12: 0.4661016949152542,
 20: 0.2796610169491526,
 22: 0.25423728813559326}

Unless, I suppose, the idea is that each roll is an additional number reported so that by roll 9, you've also seen 5 and 6 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant