Here we show a standalone example of using PyMC3 to
estimate the parameters of a straight line model in data with Gaussian noise. The
data and model used in this example are defined in createdata.py, which can be downloaded
from here. The
script shown below can be downloaded from here.
Example code
Running the code
A description of installing PyMC3 is given here. If you have downloaded the createdata.py and test_PyMC3.py scripts into the directory ${HOME}, then you can run it using:
python test_PyMC3.py
If you have Matplotlib installed then the script will produce a plot of the posterior distributions
on the straight line parameters $m$ and $c$.
A Python 3 Docker image with PyMC3 installed is
available, which can be used with:
docker run -it -v ${HOME}:/work mattpitkin/samplers:python3
to enter an interactive container, and then within the container the test script can be run with: