Unfortunately, pyStan is not compatible with Windows/Mac by default. However, this repository provides a containerized version that can be used on any environment. Users can add Python scripts in the ./stan/
directory, which will be automatically copied to the containerized Linux environment.
To use docker-compose
to execute a particular script named fululu.py
located in the ./stan/
directory, follow these steps:
-
Open a terminal and navigate to the directory containing the
docker-compose.yml
file and thefululu.py
script. -
Build the Docker image by running the following command:
docker-compose build
-
Once the build is complete, start the container and run the
fululu.py
script by running the following command:docker-compose run pystan python fululu.py
This command starts the container and runs the
fululu.py
script using the Python interpreter installed in the container. -
Alternatively, you can use the following command to start a Jupyter Notebook environment, which allows for creating notebooks for Bayesian data analysis:
docker-compose up
This command starts a Jupyter Notebook environment accessible at
http://127.0.0.1:8888
. -
To execute Python from inside the docker, run the following command:
docker-compose run pystan python
-
Once any of the commands finish running, the container will automatically stop and remove itself.
The scripts can be edited using any text editor. At each launch of the script using docker-compose
, the scripts will be copied to the Linux environment and executed there.
Note: Certain functions, such as plt.plot()
, do not work natively. It is better to use plt.savefig()
instead.