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

Uploaded Source

Built Distributions

pystan-2.17.0.0-cp36-cp36m-win_amd64.whl (33.0 MB view details)

Uploaded CPython 3.6m Windows x86-64

pystan-2.17.0.0-cp36-cp36m-win32.whl (32.9 MB view details)

Uploaded CPython 3.6m Windows x86

pystan-2.17.0.0-cp36-cp36m-manylinux1_x86_64.whl (55.1 MB view details)

Uploaded CPython 3.6m

pystan-2.17.0.0-cp36-cp36m-manylinux1_i686.whl (54.2 MB view details)

Uploaded CPython 3.6m

pystan-2.17.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 (35.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.17.0.0-cp35-cp35m-win_amd64.whl (33.0 MB view details)

Uploaded CPython 3.5m Windows x86-64

pystan-2.17.0.0-cp35-cp35m-win32.whl (32.9 MB view details)

Uploaded CPython 3.5m Windows x86

pystan-2.17.0.0-cp35-cp35m-manylinux1_x86_64.whl (55.1 MB view details)

Uploaded CPython 3.5m

pystan-2.17.0.0-cp35-cp35m-manylinux1_i686.whl (54.2 MB view details)

Uploaded CPython 3.5m

pystan-2.17.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 (35.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.17.0.0-cp34-cp34m-manylinux1_x86_64.whl (55.1 MB view details)

Uploaded CPython 3.4m

pystan-2.17.0.0-cp34-cp34m-manylinux1_i686.whl (54.2 MB view details)

Uploaded CPython 3.4m

pystan-2.17.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 (35.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.17.0.0-cp27-cp27mu-manylinux1_x86_64.whl (55.1 MB view details)

Uploaded CPython 2.7mu

pystan-2.17.0.0-cp27-cp27mu-manylinux1_i686.whl (54.2 MB view details)

Uploaded CPython 2.7mu

pystan-2.17.0.0-cp27-cp27m-manylinux1_x86_64.whl (55.1 MB view details)

Uploaded CPython 2.7m

pystan-2.17.0.0-cp27-cp27m-manylinux1_i686.whl (54.2 MB view details)

Uploaded CPython 2.7m

pystan-2.17.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 (35.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.17.0.0.tar.gz.

File metadata

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

File hashes

Hashes for pystan-2.17.0.0.tar.gz
Algorithm Hash digest
SHA256 27289d5c0eab1c1427d2fe3fd94b527161433fb8b039bf094ad4d73ebb595e49
MD5 99d4c817b4c70c73ddb1cbd7fdbbc691
BLAKE2b-256 2b4e79c20fd10e8e93cc2b1d95cb970c96dcf3aeae8682ecfc78e2011d3ad554

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.17.0.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 ebbd50719e773624b4299c924033d849606f8c033dd97dd3a651ab468882d398
MD5 5d78ae6ce283f203af9c884dbb2ab4b4
BLAKE2b-256 ba02a05a0a59f64d32ebb1f4d7ebff37d6cbcffa9b68ac97395a6b5f3ace3fb4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.17.0.0-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 6c807a4a0a787f4adad834895d059e4678acc03f7e38a361e13fb941d54483fe
MD5 9fe19ef249b9e7eaec7dde454747db5e
BLAKE2b-256 4ad42d6dff5b4d679a5c9e277b25b1cbe7a5a22ac498bd28c2606fe498522b8e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.17.0.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2d8930df612153d0db20eca4bac2a6b937f23e963fd68c918757949138f1e51e
MD5 78ec02c64b4b93da4d9c6e7e5e366003
BLAKE2b-256 d08f2bd43935109a06729a14dd427b70972bb19051667bece30febdc610f2880

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.17.0.0-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 ae21adf6681ff0d48185b08cda4a874018f2cd27bc391acbc92942d8519b8c48
MD5 3428a71986ee535ca88a94238e721d09
BLAKE2b-256 7637ebc53ec3676c102fad38b55f79c8acf4ee6b49a65699a7c981a9ec55915d

See more details on using hashes here.

File details

Details for the file pystan-2.17.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.17.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 7d8743882fb75ae27dbd39c4665cd2c506eae6493ec09be9267e054859b32be7
MD5 017f1e388e960173fc589365ab628f9a
BLAKE2b-256 88ed81f9b7d3ae65a2fc6a63115fc88e9d5d50eef442748c977b3ffcff063c10

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.17.0.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 e0260a8794573e643b94c207a0a8c86fca39310cfa0fcadd15d7a57b2e4a7ddd
MD5 d7a32f14589f4db6420673b78b7abdd7
BLAKE2b-256 0aed3aae53e1f37c8a63d55568acca0842fc26c5ffab78032e5b26b722e0ea67

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.17.0.0-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 08c26375b1ab4998f8ae7df71460502be9197b382ac3e49868856f3bf638944c
MD5 3d338f0504dd7a88cd1a04a55ae523fb
BLAKE2b-256 bb38bde9d6cb619879185eece6191e0fd75508aa1b548e98636f5574cd5c623f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.17.0.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0a219ebddc66db5e8dd8964d67ffcb342b153177c521e761acafcd58c55bd58f
MD5 6b526994ce3e248647b5e18472ee8621
BLAKE2b-256 112798c4a4b401dbb7728ff5b5b491f18bbe5f9e1ba779dc54cc0d5cd9a35621

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.17.0.0-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 986a066adedbfb92444f32c3dcbfa8851bee2200a881c37f9070a6c4acde723b
MD5 94b94af64812948afdab87b86ad251f8
BLAKE2b-256 c66840ee1a863c5e1fe058d820550021789225f60cb0beb583907b94b2cb0966

See more details on using hashes here.

File details

Details for the file pystan-2.17.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.17.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 440cf5309e8b921d6e2db64efc2d49d4c6d8fd98a3cb1c15203f0ca420ff1e2e
MD5 4beef0a37d3746223288a51de83de1a8
BLAKE2b-256 0d5f1890618b6383251a7ea17843a2d296e427fffbe1753a574db4caadef087d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.17.0.0-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 116d13ee6a877ce23ee7b7abc9bd4d398c79e7debf52ec7db4995d1c0c2cd57e
MD5 35db5f86ce102cc388b898008520a739
BLAKE2b-256 f74b927d4238e44c27be67c53088f7bafebef0642726ae8669c3c892c70c1621

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.17.0.0-cp34-cp34m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 5ea967817cc3e4984e746c7b619c5a1094ed6fa2efec179f0668e80ad4337562
MD5 ff37a6ee39fa54de023062dbe6b7565d
BLAKE2b-256 d4e764a25725dedc82c43e1f1a9a1c43063b29d42b45d4df88b4e956c8d04b3c

See more details on using hashes here.

File details

Details for the file pystan-2.17.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.17.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 94c3efacff56819ce56fb3ac1a2bd6f6830e1b6c068bc8ed9464c47144e78402
MD5 5afb0c0d8f1cdfedfcc1c62387ce6d41
BLAKE2b-256 df45f7c74a34428910370e8f8b1a694bb6727bada1327a95d5db443053abf105

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.17.0.0-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 c6327de6b1e372d9927b7d8006807474abf2507324e25fb4bb93510e0f897403
MD5 5a2f6213a028428b38f772ddf2294f95
BLAKE2b-256 6c5b690cf4a41a45270377499015ce94cfb6fccbc46b429509183d084b6cc720

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.17.0.0-cp27-cp27mu-manylinux1_i686.whl
Algorithm Hash digest
SHA256 48a411a9d45e7822ea89cd9acad47709a1aca2db56c0d43c71f2e378d4c1afe6
MD5 63d6d40ca2df53bc095bcf748e90b7a5
BLAKE2b-256 db548e66692d1fde7e3e77111277be5cb0ece7c9fa3c9781443b46694ef91da1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.17.0.0-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 06320a32c97b504aeca405d2b3d0171346668ce461433e678a3c120a85a24bea
MD5 e483dbb27d4fbfd5724050b224af203a
BLAKE2b-256 0a11db66e17e6ac72478357c0de10d214dd999ea579a924ef0846c38876398ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pystan-2.17.0.0-cp27-cp27m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 751d546aeaff62789c21112ddacd33e2f0c8826258fdf390273f9aea768dcbca
MD5 a12ee4df58a76b2b52b3337c80582e70
BLAKE2b-256 551b3922d0f20ce27732477f09fd232c9fd16f255c099aecc67dc92d53cb7863

See more details on using hashes here.

File details

Details for the file pystan-2.17.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.17.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 e329a107ef6d0cbb619e7b174513f155739a1b7ce1f5a46c040e725da5fa4e3f
MD5 93d61de1b4f4adfe9544c6778e7fa324
BLAKE2b-256 aad1d156e6e1726e6602fe9dbe19eb352cf69bdc18f08a49fdb65e91725cac38

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