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

Uploaded Source

Built Distributions

pystan-2.18.1.0-cp37-cp37m-manylinux1_x86_64.whl (50.0 MB view details)

Uploaded CPython 3.7m

pystan-2.18.1.0-cp37-cp37m-manylinux1_i686.whl (50.0 MB view details)

Uploaded CPython 3.7m

pystan-2.18.1.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 (52.1 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.18.1.0-cp36-cp36m-manylinux1_x86_64.whl (50.0 MB view details)

Uploaded CPython 3.6m

pystan-2.18.1.0-cp36-cp36m-manylinux1_i686.whl (50.0 MB view details)

Uploaded CPython 3.6m

pystan-2.18.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 (52.1 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.18.1.0-cp35-cp35m-manylinux1_x86_64.whl (50.0 MB view details)

Uploaded CPython 3.5m

pystan-2.18.1.0-cp35-cp35m-manylinux1_i686.whl (50.0 MB view details)

Uploaded CPython 3.5m

pystan-2.18.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 (52.1 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.18.1.0-cp27-cp27mu-manylinux1_x86_64.whl (50.0 MB view details)

Uploaded CPython 2.7mu

pystan-2.18.1.0-cp27-cp27mu-manylinux1_i686.whl (50.0 MB view details)

Uploaded CPython 2.7mu

pystan-2.18.1.0-cp27-cp27m-manylinux1_x86_64.whl (50.0 MB view details)

Uploaded CPython 2.7m

pystan-2.18.1.0-cp27-cp27m-manylinux1_i686.whl (50.0 MB view details)

Uploaded CPython 2.7m

pystan-2.18.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 (52.1 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.18.1.0.tar.gz.

File metadata

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

File hashes

Hashes for pystan-2.18.1.0.tar.gz
Algorithm Hash digest
SHA256 f8d50218d00848bff7cc9f33471eb5c0cf0f84af0a807963349a7931bb782b46
MD5 f502c2a631be99cf758d567c6d17dd29
BLAKE2b-256 96216452aadcbb5807fb8858e8789c74d62f5ebaece0351ff231f44064c44b33

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pystan-2.18.1.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 943de835e14111b620daaea5714c0928669c8df161dd36b3831e9ba3fc4c1a5c
MD5 d2a7ae5cca0236a7b23b3d6cce2fb481
BLAKE2b-256 a5c22831ae9d73f8e2a8af1f0ed0d51abdefaeabc43cf54cce83c852388d0971

See more details on using hashes here.

File details

Details for the file pystan-2.18.1.0-cp37-cp37m-manylinux1_i686.whl.

File metadata

  • Download URL: pystan-2.18.1.0-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 50.0 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.5

File hashes

Hashes for pystan-2.18.1.0-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 0e6fb712a178eb9cf5ea2f3922da6fc88aad183fa948db283798559e33217522
MD5 5e51d0235e9d450a9c5b7d7fca237c68
BLAKE2b-256 da0a4801521af0cdf0a635e977c9e5bc194589dd28b6cc0cb97eeb1d3c3c3431

See more details on using hashes here.

File details

Details for the file pystan-2.18.1.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.18.1.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 69e326456d1e0cebe056f70fdd891309061ab121470781e1f6db70e9c384fec8
MD5 ec1f6b42061d3c8ebd0bdef8883e2b2b
BLAKE2b-256 7a9235092c4210fbbdc878e986bd75b0acdafc735771196f08f0705522ec1a5e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pystan-2.18.1.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 cc0bb600f402166c9a96857cf6f9ffba61db610eb16eedd8c01a6f1cfeb5c09c
MD5 fc8cd636a7193080db59bb441b63c622
BLAKE2b-256 1777dd86797a7e7fccca117233c6d50cc171e0c2b2f5a0cd2a8d9753ee09b7be

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pystan-2.18.1.0-cp36-cp36m-manylinux1_i686.whl
  • Upload date:
  • Size: 50.0 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.5

File hashes

Hashes for pystan-2.18.1.0-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 d5917811afcd968618a139aaa79219f2eeb3917b773023b618524b20254e2c69
MD5 effcaf8464e5626f9bacf9c4b28a3e3f
BLAKE2b-256 e9429c544df978d64ccfb83756b195e2c65774c76aa5c358bfc9f602127adba3

See more details on using hashes here.

File details

Details for the file pystan-2.18.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.18.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 1aedf524b50065f8321a3e4e4a70d388c478cbd1e0bd04d53285f99160a956bf
MD5 b701283bc52f358e63f0bc4b575e68ee
BLAKE2b-256 5f494a02088c14cdec2e8c40337a819d55677dc64d564526009b08e6cb7422fd

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pystan-2.18.1.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b068a4451f88a9e0145d424dc495481f9f159d688966632a4b10ff608ec3ef08
MD5 387b83e072be01ce514c7804aaf86144
BLAKE2b-256 ae1f3ae727fc09aa989c8b8e9589bd7c4a8db3773a19c6c235c3add64cd82bc1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pystan-2.18.1.0-cp35-cp35m-manylinux1_i686.whl
  • Upload date:
  • Size: 50.0 MB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.5

File hashes

Hashes for pystan-2.18.1.0-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 6ad4d772d0f700b56295184e314bdb1bf71ae057400ef66eba0b27e244a17bd2
MD5 4a9e1b52279183f808b4352c4643c8d2
BLAKE2b-256 c589caafa9efc46f269718d27b3e45c99fcf51d03e89e1df8e940bbf28b53bfa

See more details on using hashes here.

File details

Details for the file pystan-2.18.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.18.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 16332424fa53476dd54b83f304297607c2d3f747c0718243420a36044ba45031
MD5 f18ff620d68d84eeec91119d3ac63c2a
BLAKE2b-256 e309ea6ab8e1befaf8732cb5b850834d051040c04f0378f6b10b8a1844d82c5f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pystan-2.18.1.0-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ccf8209733d662ee303282c1d066d57113eecf3d44965fcd267606e4a7bc5761
MD5 1b6728e311eda4cdfc0881e10a6a5324
BLAKE2b-256 d84368ca14d77b0e22092055f774fdae8141960f058aa9b9d2e3a412242761ee

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pystan-2.18.1.0-cp27-cp27mu-manylinux1_i686.whl
  • Upload date:
  • Size: 50.0 MB
  • Tags: CPython 2.7mu
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.5

File hashes

Hashes for pystan-2.18.1.0-cp27-cp27mu-manylinux1_i686.whl
Algorithm Hash digest
SHA256 71e5a9cf79b658f7959491810fcac5396c7d2df40a30f10893680f90d2cba77d
MD5 b1b6c6620dabc80a8074e0705263b17e
BLAKE2b-256 27145a4e1f833b4c393c537d0b34bbd803b5e43703872c4a8ca6e397a22860be

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pystan-2.18.1.0-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 c316579ae0451812bca5841783aefd91a5769393170e646d3b2773406eccfa31
MD5 04eed73cdf07a1766e0e959ba455318e
BLAKE2b-256 db80e05f2aaee94584aa47e52a0f41fe91933699a793836e11482b4bb1c10360

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pystan-2.18.1.0-cp27-cp27m-manylinux1_i686.whl
  • Upload date:
  • Size: 50.0 MB
  • Tags: CPython 2.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.5

File hashes

Hashes for pystan-2.18.1.0-cp27-cp27m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 bec17a2e5529900761ea91adb5c3fc2a70637d200fbd238a2e3e6df17b5685fb
MD5 5aa7ff0b689c10f18245991654c5b9ab
BLAKE2b-256 99f2cd9d22688f817d44c67c814ff0dad8fae881e5bfa9a73e7284a67478a787

See more details on using hashes here.

File details

Details for the file pystan-2.18.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.18.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 33b6fdfa23fc94653f366204e87c418b0a837739a842533ac31e69aface705a5
MD5 9d0a434b0ae5e87ee453b1ec2f88e2be
BLAKE2b-256 23bef3afa44f9309c59d49c22ae2b908dc7dfb93fec967f89595adbeb7adec54

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