PyData2015
PyData2015 copied to clipboard
die_rolled error
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.