Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download

📚 The CoCalc Library - books, templates and other resources

Views: 96160
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 dice import Dice
9
import thinkplot
10
11
12
class Train(Dice):
13
"""Represents hypotheses about how many trains the company has.
14
15
The likelihood function for the train problem is the same as
16
for the Dice problem.
17
"""
18
19
20
def main():
21
hypos = xrange(1, 1001)
22
suite = Train(hypos)
23
24
suite.Update(60)
25
print suite.Mean()
26
27
thinkplot.PrePlot(1)
28
thinkplot.Pmf(suite)
29
thinkplot.Save(root='train1',
30
xlabel='Number of trains',
31
ylabel='Probability',
32
formats=['pdf', 'eps'])
33
34
35
if __name__ == '__main__':
36
main()
37
38