Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
allendowney
GitHub Repository: allendowney/thinkbayes2
Path: blob/master/scripts/train.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
9
10
from dice import Dice
11
import thinkplot
12
13
14
class Train(Dice):
15
"""Represents hypotheses about how many trains the company has.
16
17
The likelihood function for the train problem is the same as
18
for the Dice problem.
19
"""
20
21
22
def main():
23
hypos = range(1, 1001)
24
suite = Train(hypos)
25
26
suite.Update(60)
27
print(suite.Mean())
28
29
thinkplot.PrePlot(1)
30
thinkplot.Pmf(suite)
31
thinkplot.Save(root='train1',
32
xlabel='Number of trains',
33
ylabel='Probability',
34
formats=['pdf', 'eps'])
35
36
37
if __name__ == '__main__':
38
main()
39
40