Here we show a standalone example of using PyStan 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 PyStan is given here. If you have downloaded the createdata.py and test_PyStan.py scripts into the directory ${HOME}, then you can run it using:
python test_PyStan.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 PyStan 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: