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

Uploaded Source

Built Distributions

pystan-2.17.1.0-cp36-cp36m-win_amd64.whl (45.5 MB view details)

Uploaded CPython 3.6m Windows x86-64

pystan-2.17.1.0-cp36-cp36m-win32.whl (45.3 MB view details)

Uploaded CPython 3.6m Windows x86

pystan-2.17.1.0-cp36-cp36m-manylinux1_x86_64.whl (68.1 MB view details)

Uploaded CPython 3.6m

pystan-2.17.1.0-cp36-cp36m-manylinux1_i686.whl (67.2 MB view details)

Uploaded CPython 3.6m

pystan-2.17.1.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 (48.0 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.17.1.0-cp35-cp35m-win_amd64.whl (45.5 MB view details)

Uploaded CPython 3.5m Windows x86-64

pystan-2.17.1.0-cp35-cp35m-win32.whl (45.3 MB view details)

Uploaded CPython 3.5m Windows x86

pystan-2.17.1.0-cp35-cp35m-manylinux1_x86_64.whl (68.1 MB view details)

Uploaded CPython 3.5m

pystan-2.17.1.0-cp35-cp35m-manylinux1_i686.whl (67.2 MB view details)

Uploaded CPython 3.5m

pystan-2.17.1.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 (48.0 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.17.1.0-cp34-cp34m-manylinux1_x86_64.whl (68.1 MB view details)

Uploaded CPython 3.4m

pystan-2.17.1.0-cp34-cp34m-manylinux1_i686.whl (67.2 MB view details)

Uploaded CPython 3.4m

pystan-2.17.1.0-cp27-cp27mu-manylinux1_x86_64.whl (68.1 MB view details)

Uploaded CPython 2.7mu

pystan-2.17.1.0-cp27-cp27mu-manylinux1_i686.whl (67.2 MB view details)

Uploaded CPython 2.7mu

pystan-2.17.1.0-cp27-cp27m-manylinux1_x86_64.whl (68.1 MB view details)

Uploaded CPython 2.7m

pystan-2.17.1.0-cp27-cp27m-manylinux1_i686.whl (67.2 MB view details)

Uploaded CPython 2.7m

pystan-2.17.1.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 (48.0 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.17.1.0.tar.gz.

File metadata

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

File hashes

Hashes for pystan-2.17.1.0.tar.gz
Algorithm Hash digest
SHA256 d4f91b5300c002448c4141abb806264f929fffed4fb72b9dbdfd2def83529b78
MD5 b2c842cdec14892d6e392b56fc17bc2b
BLAKE2b-256 4069259304776a6fca45b70e1577c184c2ef6de00630be2e26cd5d5a63581fb2

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for pystan-2.17.1.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 72dd9f85bca39a8b30bdd0554a805fd45334227b1a09a237b47fe016f195859c
MD5 e65422341a93adb6f73944a1d4c8d976
BLAKE2b-256 c190f6d75500d72f81d171ae2d095c70b7590dc55f2fbc63a0a76d34792dcc71

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for pystan-2.17.1.0-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 180292d5fa150c09346bccfa7136709164bbe1584c0bb925e7cda94fb0f1a08c
MD5 a955ff07e015593fd84e784eff7d017e
BLAKE2b-256 8edcb7d21c895e8c171fc781a810967fb7be7c08f1d4b305829890b4461838b4

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for pystan-2.17.1.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 606f02f80bd50722b0e07717417a9190af95abe47f22d05998d7076a832f3fe1
MD5 777ec1101be65bb6f6910434f8745b43
BLAKE2b-256 4637801a5a932e7f1f038542e7c5e4c4010aac19a26ea6bde9534505465f8c8c

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for pystan-2.17.1.0-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 ca1f01524f317f1316d48769d15bce294046f36177749b4f25b582c98da4435c
MD5 05cfea891fa43a86b1325f042473ab57
BLAKE2b-256 828f21453b6e1d05ac0aef7fec93312633c4f2ce88f97cd9e07ca89c1ca13202

See more details on using hashes here.

Provenance

File details

Details for the file pystan-2.17.1.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.17.1.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 438c4773760a1e8b48dc266bb58c8a808de79a56beb80751050e679b4c72dc9e
MD5 66e3ef10a9f8ad0f6bb05d3e70273a68
BLAKE2b-256 b33cdce0eae3f03bae8fc9af88e2dc12526081b53e4889a387f550d4daefe8db

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for pystan-2.17.1.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 836a0ca5e99d9ebeaa75a16d389f726e16aba2bc1dc6558db470272f4c1d366a
MD5 b12f88cd8d631bf5b174e75ca06daaa0
BLAKE2b-256 9a0fb76ab727cc1e58b4102aff1ffc6b5dfa45428135bda410393c91b0503d66

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for pystan-2.17.1.0-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 a19341f224b0c8065db01f51474a8f013bb7c71fff281a745952b747cffc069f
MD5 27650a7be0b6c21bd64c5ba5d7bbb2bc
BLAKE2b-256 09cbd314296c335300760581af6659ad533abf34001433c243bed416b4d73b3d

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for pystan-2.17.1.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9d0cb6a80f884570a655ff7cbee1ae80f6e47469ea660a660770c397a4b9bb49
MD5 662f60595ebd18479700aeb02c36e1d8
BLAKE2b-256 96621b9e1d0a4ce73f1f649c2d1370c1bc33a4933c127716490528ca3bfc043d

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for pystan-2.17.1.0-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 0005fe4eb3131f07c3741b05a2cdf3d1e419ef476ff57fe945a6bf9d5de80c40
MD5 be4fc50bb58851e5ab260558a6ed01be
BLAKE2b-256 1e1ac88a3f3b46d13d77d512e8452c88b2569bd7bd63ee1a1c1f09231b720274

See more details on using hashes here.

Provenance

File details

Details for the file pystan-2.17.1.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.17.1.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 3a034db3e176ea2cf2c61b10c425b26636220e700dc406fef3b1fad16d8b209a
MD5 2243550f394bd995ca9a04abba35180d
BLAKE2b-256 13492f13ee2ba2f6ff4691378886921f9ccd22c23682c81b96447b2df802b511

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for pystan-2.17.1.0-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 fe5998a813203ac865a51e7f7e7accdc306ac040d62c1d0f68a0f250c450705f
MD5 a85655611d02897530bcafb95c2995cb
BLAKE2b-256 afab20a2080abef58c6836a868c1bbe22740e6b4be68b8ba4e594f85140f6a88

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for pystan-2.17.1.0-cp34-cp34m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 cdce41fbcb5c4a248d3db1833f500c4fec5ee72c36fbcd60aaacfe3970d6d3ee
MD5 4141180278bc296aa482045420ddc488
BLAKE2b-256 35a574fc71a9f9906aee05888199774649f6af8d66d28c138d780f96ff1e9a40

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for pystan-2.17.1.0-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d856eeae100a499e69840c26d75d511a98b564f21efc8d7f9431846dc7fcfee9
MD5 6ffb9fc3f2487b5b132eb6dcd4b02938
BLAKE2b-256 9f130bb28e764406b3f184eff37bbdb6d3749a48fdf70634df0db1ef8dee7664

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for pystan-2.17.1.0-cp27-cp27mu-manylinux1_i686.whl
Algorithm Hash digest
SHA256 bdaf04bb7b617c2efd66e0c980a3552219f0fdbd67016eaa11989458d06242d3
MD5 4181af86a40f5a3ff0b49ce821c88c06
BLAKE2b-256 5d46dc1fbdf1d4781245ed6379250bf7dbd9f1c121a1c25927435ee5eea632de

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for pystan-2.17.1.0-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 882b8f137ee1f4daa6fab0821acd6de4c403e9ef7dc4f213a935153ffe76ce3c
MD5 c985058469ecf8c4110a6ac5bcb2c7dd
BLAKE2b-256 770ffc5abd1b34789ad38fb6c72c674f9001a587c0b4b91c300f16c2e20dc3dd

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for pystan-2.17.1.0-cp27-cp27m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 fdb04e7c7100d119c08950df0f5ba2f7939bb0e60f7f1230476e1a03a7deb801
MD5 fb3aca5ce4fa46c94476d2f9c9e9b3b1
BLAKE2b-256 cbb16c5255623700f4a5804691d4c15dba9bab5f948a89d8ae05cdd2ba347311

See more details on using hashes here.

Provenance

File details

Details for the file pystan-2.17.1.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.17.1.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 90e6fecd6f33530f09294db25d0ce9f1bc7527334084bb5cb81289b24f2c8cf8
MD5 9788da39c4e04600300fb24d30d08430
BLAKE2b-256 96d033e70212ea5c8eb305671079247b098c75ad0188919941fa5f50dd53756e

See more details on using hashes here.

Provenance

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