Kernel: Python 3
In [1]:
Code 2.1
In [2]:
array([ 0. , 0.15, 0.4 , 0.45, 0. ])
Code 2.2
The probability of observing six W’s in nine tosses—under a value of p=0.5
In [3]:
0.16406250000000006
Code 2.3 and 2.5
Computing the posterior using a grid approximation.
In the book the following code is not inside a function, but this way is easier to play with different parameters
In [4]:
Code 2.3
In [5]:
Code 2.6
Computing the posterior using the quadratic approximation
In [6]:
logp = -1.8075, ||grad|| = 1.5: 100%|██████████| 7/7 [00:00<00:00, 120.75it/s]
(array(0.6666666671652423), array([ 0.15713484]))
In [7]:
array([ 0.41553484, 0.91779849])
Code 2.7
In [8]:
In [9]:
This notebook was createad on a computer x86_64 running debian stretch/sid and using:
Python 3.6.2
IPython 6.1.0
PyMC3 3.2
NumPy 1.13.3
SciPy 0.19.1
Matplotlib 2.1.0