Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
allendowney
GitHub Repository: allendowney/thinkbayes2
Path: blob/master/scripts/monty2.py
1901 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 thinkbayes2 import Suite
11
12
13
class Monty(Suite):
14
def Likelihood(self, data, hypo):
15
"""Computes the likelihood of the data under the hypothesis.
16
17
hypo: string name of the door where the prize is
18
data: string name of the door Monty opened
19
"""
20
if hypo == data:
21
return 0
22
elif hypo == 'A':
23
return 0.5
24
else:
25
return 1
26
27
28
def main():
29
suite = Monty('ABC')
30
suite.Update('B')
31
suite.Print()
32
33
34
if __name__ == '__main__':
35
main()
36
37