forked from AllenDowney/ThinkBayes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
train.py
36 lines (25 loc) · 796 Bytes
/
train.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"""This file contains code for use with "Think Bayes",
by Allen B. Downey, available from greenteapress.com
Copyright 2012 Allen B. Downey
License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html
"""
from dice import Dice
import thinkplot
class Train(Dice):
"""Represents hypotheses about how many trains the company has.
The likelihood function for the train problem is the same as
for the Dice problem.
"""
def main():
hypos = xrange(1, 1001)
suite = Train(hypos)
suite.Update(60)
print suite.Mean()
thinkplot.PrePlot(1)
thinkplot.Pmf(suite)
thinkplot.Save(root='train1',
xlabel='Number of trains',
ylabel='Probability',
formats=['pdf', 'eps'])
if __name__ == '__main__':
main()