Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
allendowney
GitHub Repository: allendowney/thinkbayes2
Path: blob/master/scripts/gps.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
from itertools import product
15
16
17
class Gps(thinkbayes2.Suite, thinkbayes2.Joint):
18
"""Represents hypotheses about your location in the field."""
19
20
def Likelihood(self, data, hypo):
21
"""Computes the likelihood of the data under the hypothesis.
22
23
hypo:
24
data:
25
"""
26
# TODO: fill this in
27
like = 1
28
return like
29
30
31
def main():
32
coords = numpy.linspace(-100, 100, 101)
33
joint = Gps(product(coords, coords))
34
35
joint.Update((51, -15))
36
joint.Update((48, 90))
37
38
pairs = [(11.903060613102866, 19.79168669735705),
39
(77.10743601503178, 39.87062906535289),
40
(80.16596823095534, -12.797927542984425),
41
(67.38157493119053, 83.52841028148538),
42
(89.43965206875271, 20.52141889230797),
43
(58.794021026248245, 30.23054016065644),
44
(2.5844401241265302, 51.012041625783766),
45
(45.58108994142448, 3.5718287379754585)]
46
47
joint.UpdateSet(pairs)
48
49
# TODO: plot the marginals and print the posterior means
50
51
52
if __name__ == '__main__':
53
main()
54
55