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|

**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]}

fit = pystan.stan(model_code=schools_code, 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

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.15.0.1.tar.gz (25.4 MB view details)

Uploaded Source

Built Distributions

pystan-2.15.0.1-cp36-cp36m-win_amd64.whl (42.1 MB view details)

Uploaded CPython 3.6m Windows x86-64

pystan-2.15.0.1-cp36-cp36m-win32.whl (42.0 MB view details)

Uploaded CPython 3.6m Windows x86

pystan-2.15.0.1-cp36-cp36m-manylinux1_x86_64.whl (62.4 MB view details)

Uploaded CPython 3.6m

pystan-2.15.0.1-cp36-cp36m-manylinux1_i686.whl (61.6 MB view details)

Uploaded CPython 3.6m

pystan-2.15.0.1-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 (44.2 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.15.0.1-cp35-cp35m-win_amd64.whl (42.1 MB view details)

Uploaded CPython 3.5m Windows x86-64

pystan-2.15.0.1-cp35-cp35m-win32.whl (42.0 MB view details)

Uploaded CPython 3.5m Windows x86

pystan-2.15.0.1-cp35-cp35m-manylinux1_x86_64.whl (62.4 MB view details)

Uploaded CPython 3.5m

pystan-2.15.0.1-cp35-cp35m-manylinux1_i686.whl (61.6 MB view details)

Uploaded CPython 3.5m

pystan-2.15.0.1-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 (44.2 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.15.0.1-cp34-cp34m-manylinux1_x86_64.whl (62.4 MB view details)

Uploaded CPython 3.4m

pystan-2.15.0.1-cp34-cp34m-manylinux1_i686.whl (61.6 MB view details)

Uploaded CPython 3.4m

pystan-2.15.0.1-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 (44.2 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.15.0.1-cp27-cp27mu-manylinux1_x86_64.whl (62.4 MB view details)

Uploaded CPython 2.7mu

pystan-2.15.0.1-cp27-cp27mu-manylinux1_i686.whl (61.6 MB view details)

Uploaded CPython 2.7mu

pystan-2.15.0.1-cp27-cp27m-manylinux1_x86_64.whl (62.4 MB view details)

Uploaded CPython 2.7m

pystan-2.15.0.1-cp27-cp27m-manylinux1_i686.whl (61.6 MB view details)

Uploaded CPython 2.7m

pystan-2.15.0.1-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 (44.2 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.15.0.1.tar.gz.

File metadata

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

File hashes

Hashes for pystan-2.15.0.1.tar.gz
Algorithm Hash digest
SHA256 c15b6b90f5115fb786fa92977d50dbd1599965c2ad5982e44201cb052f2375a4
MD5 e86504cb7a6c3405c40cac947a6abcce
BLAKE2b-256 dd2292062d1616236f66c670125aa459bb2f35d9ea63927421265b51f26b2bb1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.15.0.1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 c782108a127b7f7b283f0707bb0b201c063c6b2758a5e32f881343239d9fc4ab
MD5 1f9f1b09b8ee120d3233d29b6e56ef5d
BLAKE2b-256 6cf724892f4ecfca285a930bd32f530088cbd65aac66b91e283a123721b32004

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.15.0.1-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 b9603e26bd6b4178c4c09dbde6edf57d582695c4e0cb9b139b44ea49db8ab063
MD5 48248acb4c0e77e22abe851d9d560925
BLAKE2b-256 05666f046eb6561d96b3821c3d09eb85dc5f0eb6bb48411817caa9ec934cdda5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.15.0.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 813f88d5215f2467fed0341fb553e60b6737f4db8d1bb122d342336b0f5319a9
MD5 b2d037e520086be28dcf64b40decf20d
BLAKE2b-256 246a787f21b9155c6ba44d3015afdd359ade32f3be3f7c77e3686bbdd82362ad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.15.0.1-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 cc5c68c199cb0525e3be2df8e6885999b51cb67f4d987440be7eefece2df9f69
MD5 0061d4be8daa275f11c030f6b21e7743
BLAKE2b-256 6fcdf52bd5cbdb7451558b5f152d58cd00611a768d27566f6299b2d6a160334d

See more details on using hashes here.

File details

Details for the file pystan-2.15.0.1-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.15.0.1-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 921c469b67a96d9160225f88dee12fab9203a6259a39740f7418342de5aa8130
MD5 6b612a586c771297c11b0f14dbc50c14
BLAKE2b-256 9826c587fef31d2d654e52dadb9cfd63679a58163d0ebbc99b64fb241485b89f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.15.0.1-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 57eb433b1671c18a50ea76516002c7683ca5e018b77226a3802debad1216177d
MD5 27b9048a7690658dab6df45f897fdb78
BLAKE2b-256 4b16d67bfe11fa66de8b5b746eb63c3efbae22e3fcb6f0b5fdfa2608ab7e9da6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.15.0.1-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 f45bf44fa3dc64230be033cd45e48088c383ae53203f82ca4d7e2124221f684b
MD5 69d644c99d751be083575b17314ddcf0
BLAKE2b-256 75a1726f13486091d56cab06d58c8bc6dbeb754c409a81fed5bf5cb11a55c71c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.15.0.1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 fc2add62db8c6aea5389367398d1691d0801d687ea04dd3a18f4e9c86716c94a
MD5 6d37d67b749f94634a160b92719d7f91
BLAKE2b-256 00b1a913c479854da4ab516f944a4cbd3e19790808bc88f9551bcb60ed28cb31

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.15.0.1-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 6806e964cd4215f79a47479aa8aba28ed20324613357469e6989ae68047b1fd8
MD5 1ad24f95d7c2ca5b8ea92f8511818d91
BLAKE2b-256 ea87c02b910ee7bd6a1b4479885bce578ceb2715573e49a6dccf9b3a6eeccda4

See more details on using hashes here.

File details

Details for the file pystan-2.15.0.1-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.15.0.1-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 6880fecf43e7d9781130f96192a2042becf675c518277714e5a2d7a083b8e339
MD5 f769eb7c82e4f101da1c0bc327e001a1
BLAKE2b-256 33372685a14ad960dbf8cdeba32b390ca9818619cd7719e0ce1f47a1b29df537

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.15.0.1-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 51895dae6a0c3bd676caacac5d232dc13edb9ffee6b8a98cf1b2c4ccedd3326e
MD5 48b454cd2cab81866decb2c5bc8036d9
BLAKE2b-256 74651465f73428e144ed6de2252a1b1dbab07ccfccff1391867ebf00716bbd2d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.15.0.1-cp34-cp34m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 957c6d2b9093a507ea849972b5d23a3eec17c1cbbeb51e15441ffac8f6f73a30
MD5 0ec1a10619a169a280b15da6980c4ce9
BLAKE2b-256 dda1876effa126fc14a3802dc7e92de49b002a285c42146508d3abb36e23bf38

See more details on using hashes here.

File details

Details for the file pystan-2.15.0.1-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.15.0.1-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 0e405e439d8959776a575ecc69d6b07bcfd161a7e19d4a6fb5f9bdeb60190928
MD5 ba1acb816c1bbe65ca1c4298e9bd3f9c
BLAKE2b-256 dece398f4586fbd4f6c4a4d66e5338dede76d503ce29c02a90737c00fa56057f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.15.0.1-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d08c4c9f1ccc8afd07980febe111bf4994f2fe8630d0ddaeba3c726bb5dd513c
MD5 7fa5d01ce1b4ea8b25efe8b551b54a73
BLAKE2b-256 39248b172417043f2bed1bfa9d1ababcdd5021b510fb8747666651c1eed1f832

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.15.0.1-cp27-cp27mu-manylinux1_i686.whl
Algorithm Hash digest
SHA256 d4b2705c2d3e9a20e205f4a254c680f676943aeec316c01ec36f031720d111e4
MD5 5e0957744c0f31714d3b9df80f223378
BLAKE2b-256 9676a981c24500c8988506398abbd08a3f9e38dc99e51b3d0efcd4fbe9d27665

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.15.0.1-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4350c6fc662372e7ddf60117b1fd84ebe748403aad9b9e822fa95192a5d2e44e
MD5 9424f55aff00a7543c0440c44e1f87d5
BLAKE2b-256 8521ad820f4e28357bd458418d1bc9c95a9bf00e2a21869a7933e34ef14197e2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.15.0.1-cp27-cp27m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 faec0b10f9fc57dfa4b31c3a7526c1d19499da199793a21a9c9c0140236e4324
MD5 1f58a3abb784cb46cb9de860abe495dc
BLAKE2b-256 10e9fd3817140980d0033e896e22f4e8907c5224a3dee2508a44b10b3bfa484c

See more details on using hashes here.

File details

Details for the file pystan-2.15.0.1-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.15.0.1-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 296f10824adbc09714ac63362170174f5e868dd7f240abf4a8025d59455afc9e
MD5 56824146fc95a68500ab7c031e833894
BLAKE2b-256 ed998bc64f78b8156476e66d142ef914be993caaa782b7c735ed13639966f9ea

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