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
------------------

`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.16.0.0.tar.gz (13.6 MB view details)

Uploaded Source

Built Distributions

pystan-2.16.0.0-cp36-cp36m-win_amd64.whl (32.5 MB view details)

Uploaded CPython 3.6m Windows x86-64

pystan-2.16.0.0-cp36-cp36m-win32.whl (32.4 MB view details)

Uploaded CPython 3.6m Windows x86

pystan-2.16.0.0-cp36-cp36m-manylinux1_x86_64.whl (52.9 MB view details)

Uploaded CPython 3.6m

pystan-2.16.0.0-cp36-cp36m-manylinux1_i686.whl (52.1 MB view details)

Uploaded CPython 3.6m

pystan-2.16.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 (34.6 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.16.0.0-cp35-cp35m-win_amd64.whl (32.5 MB view details)

Uploaded CPython 3.5m Windows x86-64

pystan-2.16.0.0-cp35-cp35m-win32.whl (32.4 MB view details)

Uploaded CPython 3.5m Windows x86

pystan-2.16.0.0-cp35-cp35m-manylinux1_x86_64.whl (52.9 MB view details)

Uploaded CPython 3.5m

pystan-2.16.0.0-cp35-cp35m-manylinux1_i686.whl (52.1 MB view details)

Uploaded CPython 3.5m

pystan-2.16.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 (34.6 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.16.0.0-cp34-cp34m-manylinux1_x86_64.whl (52.9 MB view details)

Uploaded CPython 3.4m

pystan-2.16.0.0-cp34-cp34m-manylinux1_i686.whl (52.1 MB view details)

Uploaded CPython 3.4m

pystan-2.16.0.0-cp34-cp34m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (34.6 MB view details)

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

pystan-2.16.0.0-cp27-cp27mu-manylinux1_x86_64.whl (52.9 MB view details)

Uploaded CPython 2.7mu

pystan-2.16.0.0-cp27-cp27mu-manylinux1_i686.whl (52.1 MB view details)

Uploaded CPython 2.7mu

pystan-2.16.0.0-cp27-cp27m-manylinux1_x86_64.whl (52.9 MB view details)

Uploaded CPython 2.7m

pystan-2.16.0.0-cp27-cp27m-manylinux1_i686.whl (52.1 MB view details)

Uploaded CPython 2.7m

pystan-2.16.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 (34.6 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.16.0.0.tar.gz.

File metadata

  • Download URL: pystan-2.16.0.0.tar.gz
  • Upload date:
  • Size: 13.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pystan-2.16.0.0.tar.gz
Algorithm Hash digest
SHA256 6061f6d327ff4b445eeee9a489d880f3d51782f638d70481d373b643568b2e92
MD5 867e1410da2d22d4cb2ea9b8a8d1fb21
BLAKE2b-256 bb51199328aec724d3ed6cbe91b92ad526f45e5c201095c7ca69a00a9a200ffa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.16.0.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 e04f54630f4573187c4e0704abcbfdf7a886fa6c8786c5d655ce4eb97f03c8da
MD5 289f1a444e261d6f17f4918ced3f37fa
BLAKE2b-256 f035d0a7788feef09e6f5ddf6ba63734d221cd4d0799d09690e29824f56caf51

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.16.0.0-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 0fe3e585e74acc3b25b8fe258e15a068141cdbd2011daefb2ca1bb27da6c43f8
MD5 6e7d7add043749cd2215efe56f93b6e5
BLAKE2b-256 62bdd4bf17e31a25ad6c3091e7ef66d9744dc54429ab911d2b781121aec652ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.16.0.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 5fc7adbe920278eb3f388a42467f9430e0d3b97e4ec3db32dbcec5b30569d70d
MD5 c66866e585b0eb313fce306046e65e36
BLAKE2b-256 7187b4a3af126a07aad3a8cd155f8042a917ecfc04fad02606a705175783cc07

See more details on using hashes here.

File details

Details for the file pystan-2.16.0.0-cp36-cp36m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for pystan-2.16.0.0-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 b15478f7e73c37cfba5e6fafe73c64adb8f865b3d6b858f5a48be819fcca2727
MD5 285e4b22d41003d79163f8e5cb339eae
BLAKE2b-256 198038397de73ca38a8f84d06db63538ccd967e79c24b3a4f995531da336ae9e

See more details on using hashes here.

File details

Details for the file pystan-2.16.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.16.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 89dd0975af5d150df5057c858a5d20b38a60dadb85f2d2204474c445a643ec09
MD5 7614e3af638898ecd229832ba79e962b
BLAKE2b-256 9a3f8da67e31a500489fb94e55b704acbd72591179817cb8e195c8646faebaf8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.16.0.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 3f826bf9830d48ebf49913ab41a6af5edc08bce88b3a118029ee72d3e2ee4d43
MD5 c3d7df4eb554ef7badd5c6bd38e1dbdd
BLAKE2b-256 2e0e3b50ac69bafdd26820fc6842662cfd9dbb7e9e64ee0a53144cbfabca1f49

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.16.0.0-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 c4b70c476fe4accd8560feed544f8bb09bd9f69d0109a732c80184c6c6cc9721
MD5 51e57162e8f02c4561cb9facab1e89d6
BLAKE2b-256 a03f4b84dcb67f6e4e9facb43f9eda5358b72712ec18e65ff13466223d6b4ff7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.16.0.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 889de550e63ba37c0dd1bb01a4fd13a71fa6a13337681dd6912bb7764adab78f
MD5 3ab03d6d42766abc4d1c1bac618424ac
BLAKE2b-256 11490d735266c4cb5c30e9df3e9be274c5dba0bd07c894cabe42e359599cc00a

See more details on using hashes here.

File details

Details for the file pystan-2.16.0.0-cp35-cp35m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for pystan-2.16.0.0-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 8709332af2310dcb76a7f055900c3375fa64f5365ce490f40c651fb4b563c214
MD5 789127af52b9d12d9172bd79cdf6aad0
BLAKE2b-256 1164e74f973e95b910dcfbdd36b70c0af547f82955c180a82cfc7f484fbf7370

See more details on using hashes here.

File details

Details for the file pystan-2.16.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.16.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 979d7a97fc334ea498f97f05be16b9feaa7d9317b65b1d7847ae1421d407834a
MD5 e248e8c54d125d33ea1c5265c71888aa
BLAKE2b-256 cfd1b7e618e63e4bd8a0aad75ae018115a1e0a17237bf67316624fcad53381b3

See more details on using hashes here.

File details

Details for the file pystan-2.16.0.0-cp34-cp34m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pystan-2.16.0.0-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 aeaf41f4abf8e320a5d3ab54972bad8e74fbac1ea8dd62507d981b18d173936a
MD5 c144726d623161d4b59dd41f176df62b
BLAKE2b-256 573d7bd1df0b321323d9047e18c68028e841a912551157cfcbb8f75d5983e603

See more details on using hashes here.

File details

Details for the file pystan-2.16.0.0-cp34-cp34m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for pystan-2.16.0.0-cp34-cp34m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 214bb1046ce5a002455c77619b583fab556c33cb24f714171eb0edc6e184723f
MD5 f960b96553f8f1895574d5560afc5e8b
BLAKE2b-256 d91898f8d95436c7777f65975969d77e7c6f78690960f28a22c1a53ed504edb0

See more details on using hashes here.

File details

Details for the file pystan-2.16.0.0-cp34-cp34m-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.16.0.0-cp34-cp34m-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 8f40b79a6acb871fe9672bdac7dfca588b6ea0506c48b633895488e36c44ba95
MD5 54e120243d2441c57902242f724a7a72
BLAKE2b-256 eda82fb975c924c311d75390224353da3921370c2c233fcf91b4723bcc4375ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.16.0.0-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 bea7da71cf60a10969b0c3527f3eed9bc26849ed93077ce46f773999b8fa71f1
MD5 a2597911e9f2ba39e2e461695fbffa31
BLAKE2b-256 d0d6cb96a18bc3c59869586ee7a4449b16da528ed3274a49c098c169ea0bb666

See more details on using hashes here.

File details

Details for the file pystan-2.16.0.0-cp27-cp27mu-manylinux1_i686.whl.

File metadata

File hashes

Hashes for pystan-2.16.0.0-cp27-cp27mu-manylinux1_i686.whl
Algorithm Hash digest
SHA256 2307bacbb3b41a6a659ac11c895e26dfdc9ab8e3669cb0650a3948ba8c88b845
MD5 4c7ff7fd12329e5e229cb899f6a1ef66
BLAKE2b-256 066a95daaa273a0dffd9ba9ba11c84eff2e96e2e142a1fd84300e7ace2c22483

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.16.0.0-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 41100e2b7b1a93b7f34ee8aaf2cfbbc2b5d319b46434cd0862d8e661283c9d78
MD5 b8a91089df99023e2d49d9fef3e2f5bd
BLAKE2b-256 dc62a805ac114097f101c0d6150f22cc8701a61295cd46671e10529f60367227

See more details on using hashes here.

File details

Details for the file pystan-2.16.0.0-cp27-cp27m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for pystan-2.16.0.0-cp27-cp27m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 80dc6fd8e8ae037402a3b8c499ceb523fe92782b91ab985cf4b42ccacd33c090
MD5 e6da9f33779f9c0085f5a10c44a7f46b
BLAKE2b-256 52566b6dce9e5a888f4fbcb1ab702f83524f6ae5937f988ce1a83cc076e4859f

See more details on using hashes here.

File details

Details for the file pystan-2.16.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.16.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 27025541a1a7ff5455aac15ac7e2be815d8663ceab584a8d72863390b7ca355c
MD5 94668e19f43e88b9eba3f08552d155d2
BLAKE2b-256 06ef9cd515af82123aefafbd4a0bfb371dfb7e01d1f8f1b6d66aadd1cd1c64ea

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