Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Repository for a workshop on Bayesian statistics

1430 views
1
"""This file contains code for use with "Think Bayes",
2
by Allen B. Downey, available from greenteapress.com
3
4
Copyright 2012 Allen B. Downey
5
License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html
6
"""
7
8
from __future__ import print_function, division
9
10
from thinkbayes import Suite
11
12
13
class Dice(Suite):
14
"""Represents hypotheses about which die was rolled."""
15
16
def Likelihood(self, data, hypo):
17
"""Computes the likelihood of the data under the hypothesis.
18
19
hypo: integer number of sides on the die
20
data: integer die roll
21
"""
22
# write this method
23
return 1
24
25
26
def main():
27
suite = Dice([4, 6, 8, 12, 20])
28
29
suite.Update(6)
30
print('After one 6')
31
suite.Print()
32
33
for roll in [8, 7, 7, 5, 4]:
34
suite.Update(roll)
35
36
print('After more rolls')
37
suite.Print()
38
39
40
if __name__ == '__main__':
41
main()
42
43