/
electorate.py
42 lines (28 loc) · 872 Bytes
/
electorate.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
37
38
39
40
41
42
"""This file contains code for use with "Think Bayes",
by Allen B. Downey, available from greenteapress.com
Copyright 2014 Allen B. Downey
License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html
"""
from __future__ import print_function, division
import numpy
import thinkbayes2
import thinkplot
class Electorate(thinkbayes2.Suite):
"""Represents hypotheses about the state of the electorate."""
def Likelihood(self, data, hypo):
"""Computes the likelihood of the data under the hypothesis.
hypo:
data:
"""
like = 1
return like
def main():
hypos = numpy.linspace(0, 100, 101)
suite = Electorate(hypos)
thinkplot.Pdf(suite, label='prior')
data = 1.1, 3.7, 53
suite.Update(data)
thinkplot.Pdf(suite, label='posterior')
thinkplot.Show()
if __name__ == '__main__':
main()