Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download

📚 The CoCalc Library - books, templates and other resources

Views: 96163
License: OTHER
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 thinkbayes import Suite
9
10
11
class Monty(Suite):
12
def Likelihood(self, data, hypo):
13
"""Computes the likelihood of the data under the hypothesis.
14
15
hypo: string name of the door where the prize is
16
data: string name of the door Monty opened
17
"""
18
if hypo == data:
19
return 0
20
elif hypo == 'A':
21
return 0.5
22
else:
23
return 1
24
25
26
def main():
27
suite = Monty('ABC')
28
suite.Update('B')
29
suite.Print()
30
31
32
if __name__ == '__main__':
33
main()
34
35