Skip to main content

Python interface to Stan, a package for Bayesian inference

Project description

PyStan: The Python Interface to Stan
====================================

.. image:: https://raw.githubusercontent.com/stan-dev/logos/master/logo.png
:alt: Stan logo
:scale: 50 %

|pypi| |travis| |appveyor| |zenodo|

**PyStan** provides a Python interface to Stan, a package for Bayesian inference
using the No-U-Turn sampler, a variant of Hamiltonian Monte Carlo.

For more information on `Stan <http://mc-stan.org>`_ and its modeling language,
see the Stan User's Guide and Reference Manual at `http://mc-stan.org/
<http://mc-stan.org/>`_.

Important links
---------------

- HTML documentation: https://pystan.readthedocs.org
- Issue tracker: https://github.com/stan-dev/pystan/issues
- Source code repository: https://github.com/stan-dev/pystan
- Stan: http://mc-stan.org/
- Stan User's Guide and Reference Manual (pdf) available at http://mc-stan.org

Related projects
----------------

- Scikit-learn integration: `pystan-sklearn <https://github.com/rgerkin/pystan-sklearn>`_ by @rgerkin.

Similar projects
----------------

- PyMC: http://pymc-devs.github.io/pymc/

Detailed Installation Instructions
----------------------------------
Detailed installation instructions can be found in the
`doc/installation_beginner.md <https://github.com/chendaniely/pystan/blob/develop/doc/installation_beginner.rst/>`_ file.

Quick Installation (Linux and macOS)
------------------------------------

`NumPy <http://www.numpy.org/>`_ and `Cython <http://www.cython.org/>`_
(version 0.22 or greater) are required. `matplotlib <http://matplotlib.org/>`_
is optional.

PyStan and the required packages may be installed from the `Python Package Index
<https://pypi.python.org/pypi>`_ using ``pip``.

::

pip install pystan

Alternatively, if Cython (version 0.22 or greater) and NumPy are already
available, PyStan may be installed from source with the following commands

::

git clone --recursive https://github.com/stan-dev/pystan.git
cd pystan
python setup.py install

If you encounter an ``ImportError`` after compiling from source, try changing
out of the source directory before attempting ``import pystan``. On Linux and
OS X ``cd /tmp`` will work.

Example
-------

::

import pystan
import numpy as np
import matplotlib.pyplot as plt

schools_code = """
data {
int<lower=0> J; // number of schools
real y[J]; // estimated treatment effects
real<lower=0> sigma[J]; // s.e. of effect estimates
}
parameters {
real mu;
real<lower=0> tau;
real eta[J];
}
transformed parameters {
real theta[J];
for (j in 1:J)
theta[j] = mu + tau * eta[j];
}
model {
eta ~ normal(0, 1);
y ~ normal(theta, sigma);
}
"""

schools_dat = {'J': 8,
'y': [28, 8, -3, 7, -1, 1, 18, 12],
'sigma': [15, 10, 16, 11, 9, 11, 10, 18]}

sm = pystan.StanModel(model_code=schools_code)
fit = sm.sampling(data=schools_dat, iter=1000, chains=4)

print(fit)

eta = fit.extract(permuted=True)['eta']
np.mean(eta, axis=0)

# if matplotlib is installed (optional, not required), a visual summary and
# traceplot are available
fit.plot()
plt.show()

.. |pypi| image:: https://badge.fury.io/py/pystan.png
:target: https://badge.fury.io/py/pystan
:alt: pypi version

.. |travis| image:: https://travis-ci.org/stan-dev/pystan.png?branch=master
:target: https://travis-ci.org/stan-dev/pystan
:alt: travis-ci build status

.. |appveyor| image:: https://ci.appveyor.com/api/projects/status/github/stan-dev/pystan?branch=master
:target: https://ci.appveyor.com/project/ariddell/pystan/branch/master
:alt: appveyor-ci build status
.. |zenodo| image:: https://zenodo.org/badge/10256919.svg
:target: https://zenodo.org/badge/latestdoi/10256919
:alt: zenodo citation DOI


Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pystan-2.19.0.0.tar.gz (16.5 MB view details)

Uploaded Source

Built Distributions

pystan-2.19.0.0-cp37-cp37m-win_amd64.whl (79.7 MB view details)

Uploaded CPython 3.7m Windows x86-64

pystan-2.19.0.0-cp37-cp37m-win32.whl (55.7 MB view details)

Uploaded CPython 3.7m Windows x86

pystan-2.19.0.0-cp37-cp37m-manylinux1_x86_64.whl (67.2 MB view details)

Uploaded CPython 3.7m

pystan-2.19.0.0-cp37-cp37m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (37.4 MB view details)

Uploaded CPython 3.7m macOS 10.10+ intel macOS 10.10+ x86-64 macOS 10.6+ intel macOS 10.9+ intel macOS 10.9+ x86-64

pystan-2.19.0.0-cp36-cp36m-win_amd64.whl (79.7 MB view details)

Uploaded CPython 3.6m Windows x86-64

pystan-2.19.0.0-cp36-cp36m-win32.whl (55.7 MB view details)

Uploaded CPython 3.6m Windows x86

pystan-2.19.0.0-cp36-cp36m-manylinux1_x86_64.whl (67.2 MB view details)

Uploaded CPython 3.6m

pystan-2.19.0.0-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (37.4 MB view details)

Uploaded CPython 3.6m macOS 10.10+ intel macOS 10.10+ x86-64 macOS 10.6+ intel macOS 10.9+ intel macOS 10.9+ x86-64

pystan-2.19.0.0-cp35-cp35m-win_amd64.whl (79.7 MB view details)

Uploaded CPython 3.5m Windows x86-64

pystan-2.19.0.0-cp35-cp35m-win32.whl (55.6 MB view details)

Uploaded CPython 3.5m Windows x86

pystan-2.19.0.0-cp35-cp35m-manylinux1_x86_64.whl (67.2 MB view details)

Uploaded CPython 3.5m

pystan-2.19.0.0-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (37.4 MB view details)

Uploaded CPython 3.5m macOS 10.10+ intel macOS 10.10+ x86-64 macOS 10.6+ intel macOS 10.9+ intel macOS 10.9+ x86-64

pystan-2.19.0.0-cp27-cp27mu-manylinux1_x86_64.whl (67.1 MB view details)

Uploaded CPython 2.7mu

pystan-2.19.0.0-cp27-cp27m-manylinux1_x86_64.whl (67.1 MB view details)

Uploaded CPython 2.7m

pystan-2.19.0.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (37.3 MB view details)

Uploaded CPython 2.7m macOS 10.10+ intel macOS 10.10+ x86-64 macOS 10.6+ intel macOS 10.9+ intel macOS 10.9+ x86-64

File details

Details for the file pystan-2.19.0.0.tar.gz.

File metadata

  • Download URL: pystan-2.19.0.0.tar.gz
  • Upload date:
  • Size: 16.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.5

File hashes

Hashes for pystan-2.19.0.0.tar.gz
Algorithm Hash digest
SHA256 b85301b960d5991918b40bd64a4e9321813657a9fc028e0f39edce7220a309eb
MD5 25d7f84139be513b74be03300255bfa7
BLAKE2b-256 4864dc7152b7ca88903669c296beddf3a8de839c3900684136514293dc99d432

See more details on using hashes here.

File details

Details for the file pystan-2.19.0.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: pystan-2.19.0.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 79.7 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.5

File hashes

Hashes for pystan-2.19.0.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 b8bfdc0d9cae3eb2ee627ed3a69a910b9bee14dc7332249b183018460b82e9e6
MD5 ad7cddd7d4461484535bd578a461deaf
BLAKE2b-256 d2882411ad496304673559a0dbb32b8ecd83c1fbc52cf83d9e1cca2ed66cbba6

See more details on using hashes here.

File details

Details for the file pystan-2.19.0.0-cp37-cp37m-win32.whl.

File metadata

  • Download URL: pystan-2.19.0.0-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 55.7 MB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.5

File hashes

Hashes for pystan-2.19.0.0-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 c1758a0a3580503d7b3cb54b89b84a3f37f7a67b875175a477b1958485e9d381
MD5 f32badd8bda8dc4dd80b672839b2e380
BLAKE2b-256 5921362c04918f621903d8359754fa8d6b6fcecd31765ce6f4ecd7ddfc80432f

See more details on using hashes here.

File details

Details for the file pystan-2.19.0.0-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pystan-2.19.0.0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 67.2 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.5

File hashes

Hashes for pystan-2.19.0.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2b33917067123eec8afda90942e26eb4837810c6897db1e5949b42a08d0e23b2
MD5 d04e45fed109d108c12906c9718c2351
BLAKE2b-256 7beac004537cd92c7dcc0112756d2cbc99707e3f67966e57285cdaca68b2e364

See more details on using hashes here.

File details

Details for the file pystan-2.19.0.0-cp37-cp37m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl.

File metadata

File hashes

Hashes for pystan-2.19.0.0-cp37-cp37m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 b8e6e4bef4ead53d49f59e9d30a6a7e64777db2b7d99a74e1e320f74eed4431a
MD5 a9849e500866114014e24edc71363c89
BLAKE2b-256 828b9b48058afd41c41ba704eacae7ee2186a16f2cb6e22970fc97deca8bd6df

See more details on using hashes here.

File details

Details for the file pystan-2.19.0.0-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: pystan-2.19.0.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 79.7 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.5

File hashes

Hashes for pystan-2.19.0.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 d7716156ae3739f7a38c9817824b7cf837f5e42ae2603d4020bc00a311f0df99
MD5 009ce449fb4369de0ecbc46ce590659f
BLAKE2b-256 9604857bed4cfe09994b8027e86e6fb345dfa398afc3a26cb8e2dd0d5a865cba

See more details on using hashes here.

File details

Details for the file pystan-2.19.0.0-cp36-cp36m-win32.whl.

File metadata

  • Download URL: pystan-2.19.0.0-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 55.7 MB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.5

File hashes

Hashes for pystan-2.19.0.0-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 3378fb5a7285077226bd59c6c1d1a3878f4156dc5a39e2a55f3790377afeedcf
MD5 6804da0d382d0dde339d393f21eec7df
BLAKE2b-256 7d56f86d1c39fcb4cdeafbbb8bf7df6e8238ffd11ed1f9da907f20662a5f5f75

See more details on using hashes here.

File details

Details for the file pystan-2.19.0.0-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pystan-2.19.0.0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 67.2 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.5

File hashes

Hashes for pystan-2.19.0.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 fd82b211ec57d34e7a31f0349a1fd8cf84a852744406b7df851dc8596da066e8
MD5 935dd37eeefcb29ca75b26dd70c65376
BLAKE2b-256 9fec2252bcd6d93f27e726e8616b3e7ed6fb87924aede4afbed22a490980105e

See more details on using hashes here.

File details

Details for the file pystan-2.19.0.0-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl.

File metadata

File hashes

Hashes for pystan-2.19.0.0-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 cae9dda4f5ab3c50df0a851082a2e429946f318ea0fd83301f2bae86daf43ab3
MD5 4c720ec0c473271a8524e01dc56310d5
BLAKE2b-256 01fd568f439331b7811a18367ea0f99289417fe3e8711848950e571d340cbad0

See more details on using hashes here.

File details

Details for the file pystan-2.19.0.0-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: pystan-2.19.0.0-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 79.7 MB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.5

File hashes

Hashes for pystan-2.19.0.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 c1f8271945c1f2eb89fcf5a1acbb17e9cee5f7fe606636f732c07fd22912a315
MD5 31df42f1932b6716be64b3b28891a471
BLAKE2b-256 c2f42ea598df0c0e8bf9b1e1344d370a88f639e1a86a648c859dd2f1d4b3fca1

See more details on using hashes here.

File details

Details for the file pystan-2.19.0.0-cp35-cp35m-win32.whl.

File metadata

  • Download URL: pystan-2.19.0.0-cp35-cp35m-win32.whl
  • Upload date:
  • Size: 55.6 MB
  • Tags: CPython 3.5m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.5

File hashes

Hashes for pystan-2.19.0.0-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 53193bdaa79c9c79f3deb49258f29fbe62305d2a8cdf8dc4d67c159844859935
MD5 7bb8dac5f66ce7554f8c063d5fd6addb
BLAKE2b-256 1a2cc56a8447de1e4f128c9f90be3ae45fe779ddce776345650fd45dcbc3290b

See more details on using hashes here.

File details

Details for the file pystan-2.19.0.0-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pystan-2.19.0.0-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 67.2 MB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.5

File hashes

Hashes for pystan-2.19.0.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4ee613ce1499db317e056daf7fcf7888317ebf09df673533184834d1d13d02db
MD5 24839357130d1e3bf9946a1d917fdc2a
BLAKE2b-256 43a579ff313efbf90cd2055d9a4dac550ef0cdd6609b4c559d6979782bae9824

See more details on using hashes here.

File details

Details for the file pystan-2.19.0.0-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl.

File metadata

File hashes

Hashes for pystan-2.19.0.0-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 fcd8b5186531561dfbde7ccb9416255f4c1acb69d323070c218719a436114b08
MD5 dbfe385dec0c0b844d7e7721092522a6
BLAKE2b-256 56f64c49cff1e0788e691dce819a621f07153ed5c758bf1c93c3e678a8ba3f6c

See more details on using hashes here.

File details

Details for the file pystan-2.19.0.0-cp27-cp27mu-manylinux1_x86_64.whl.

File metadata

  • Download URL: pystan-2.19.0.0-cp27-cp27mu-manylinux1_x86_64.whl
  • Upload date:
  • Size: 67.1 MB
  • Tags: CPython 2.7mu
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.5

File hashes

Hashes for pystan-2.19.0.0-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 36a0503adbfbda56be724b9f5b3444d7bc25417b51e25f4c56ce6fb4d64ff4a1
MD5 4c46f890c2f253ffdf7578d8bfd0e50c
BLAKE2b-256 acb467437c0ab7670f8da2c873eeba5543770410a69491e3df2d6c22308d26d5

See more details on using hashes here.

File details

Details for the file pystan-2.19.0.0-cp27-cp27m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pystan-2.19.0.0-cp27-cp27m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 67.1 MB
  • Tags: CPython 2.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.5

File hashes

Hashes for pystan-2.19.0.0-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 59e37a5601c53ef28031c1a0ca1b6cacafedb01d7e67f1e0d174f5ce7beb5e02
MD5 8ca564f3a48b66d93fe719369a3c680f
BLAKE2b-256 a24ae2ef79534cd839b8fe792fb7ddd7543c53c9ff6fdfb0fe0c9555e5c739cc

See more details on using hashes here.

File details

Details for the file pystan-2.19.0.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl.

File metadata

File hashes

Hashes for pystan-2.19.0.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 97375e06b1054de1e555fbe197b979836cfb2cd833dbd3d760768ea17aa41e52
MD5 c02897c7aa816cff6d7b2a25caab9019
BLAKE2b-256 ef8d223604a67214509869751002286afdfbcd49bfa4e41c3584179fb6844a5b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page