Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
allendowney
GitHub Repository: allendowney/thinkbayes2
Path: blob/master/scripts/soccer.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 2014 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
import numpy
11
import thinkbayes2
12
import thinkplot
13
14
15
class Soccer(thinkbayes2.Suite):
16
"""Represents hypotheses about."""
17
18
def Likelihood(self, data, hypo):
19
"""Computes the likelihood of the data under the hypothesis.
20
21
hypo:
22
data:
23
"""
24
like = 1
25
return like
26
27
def PredRemaining(self, rem_time, score):
28
"""Plots the predictive distribution for final number of goals.
29
30
rem_time: remaining time in the game in minutes
31
score: number of goals already scored
32
"""
33
# TODO: fill this in
34
35
36
def main():
37
hypos = numpy.linspace(0, 12, 201)
38
suite = Soccer(hypos)
39
40
thinkplot.Pdf(suite, label='prior')
41
print('prior mean', suite.Mean())
42
43
suite.Update(11)
44
thinkplot.Pdf(suite, label='posterior 1')
45
print('after one goal', suite.Mean())
46
47
thinkplot.Show()
48
49
50
if __name__ == '__main__':
51
main()
52
53