Skip to main content

PyStan: The Python Interface to Stan

Stan logo

pypi version travis-ci build status appveyor-ci build status zenodo citation DOI

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 and its modeling language, see the Stan User’s Guide and Reference Manual at http://mc-stan.org/.

Similar projects

Detailed Installation Instructions

Detailed installation instructions can be found in the doc/installation_beginner.md file.

Quick Installation

NumPy and Cython (version 0.22 or greater) are required. matplotlib is optional.

PyStan and the required packages may be installed from the Python Package Index 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()

Metadata

Release files for pystan 2.16.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pystan 2.16.0.0
File Size Uploaded
pystan-2.16.0.0.tar.gz 13.6 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for pystan 2.16.0.0
File
pystan-2.16.0.0-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
pystan-2.16.0.0-cp36-cp36m-win32.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-32 Details
pystan-2.16.0.0-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details
pystan-2.16.0.0-cp36-cp36m-manylinux1_i686.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32 Details
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 CPython 3.6 CPython 3.6 pymalloc macOS 10.10+ Intel (x86-64, i386), macOS 10.10+ x86-64, macOS 10.9+ x86-64, macOS 10.6+ Intel (x86-64, i386), macOS 10.9+ Intel (x86-64, i386) Details
pystan-2.16.0.0-cp35-cp35m-win_amd64.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-64 Details
pystan-2.16.0.0-cp35-cp35m-win32.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-32 Details
pystan-2.16.0.0-cp35-cp35m-manylinux1_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 Details
pystan-2.16.0.0-cp35-cp35m-manylinux1_i686.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32 Details
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 CPython 3.5 CPython 3.5 pymalloc macOS 10.9+ Intel (x86-64, i386), macOS 10.9+ x86-64, macOS 10.10+ Intel (x86-64, i386), macOS 10.10+ x86-64, macOS 10.6+ Intel (x86-64, i386) Details
pystan-2.16.0.0-cp34-cp34m-manylinux1_x86_64.whl CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-64 Details
pystan-2.16.0.0-cp34-cp34m-manylinux1_i686.whl CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-32 Details
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 CPython 3.4 CPython 3.4 pymalloc macOS 10.9+ Intel (x86-64, i386), macOS 10.10+ x86-64, macOS 10.9+ x86-64, macOS 10.10+ Intel (x86-64, i386), macOS 10.6+ Intel (x86-64, i386) Details
pystan-2.16.0.0-cp27-cp27mu-manylinux1_x86_64.whl CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.5+ x86-64 Details
pystan-2.16.0.0-cp27-cp27mu-manylinux1_i686.whl CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.5+ x86-32 Details
pystan-2.16.0.0-cp27-cp27m-manylinux1_x86_64.whl CPython 2.7 CPython 2.7 pymalloc Linux glibc 2.5+ x86-64 Details
pystan-2.16.0.0-cp27-cp27m-manylinux1_i686.whl CPython 2.7 CPython 2.7 pymalloc Linux glibc 2.5+ x86-32 Details
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 CPython 2.7 CPython 2.7 pymalloc macOS 10.10+ Intel (x86-64, i386), macOS 10.10+ x86-64, macOS 10.6+ Intel (x86-64, i386), macOS 10.9+ Intel (x86-64, i386), macOS 10.9+ x86-64 Details

Total release size: 806.5 MB

Release files / pystan-2.16.0.0.tar.gz

Download URL pystan-2.16.0.0.tar.gz
Size 13.6 MB
Tags Source
SHA-256 checksum
How to use checksums
6061f6d327ff4b445eeee9a489d880f3d51782f638d70481d373b643568b2e92
BLAKE2b-256 checksum
How to use checksums
bb51199328aec724d3ed6cbe91b92ad526f45e5c201095c7ca69a00a9a200ffa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pystan-2.16.0.0-cp36-cp36m-win_amd64.whl

Download URL pystan-2.16.0.0-cp36-cp36m-win_amd64.whl
Size 32.5 MB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
e04f54630f4573187c4e0704abcbfdf7a886fa6c8786c5d655ce4eb97f03c8da
BLAKE2b-256 checksum
How to use checksums
f035d0a7788feef09e6f5ddf6ba63734d221cd4d0799d09690e29824f56caf51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pystan-2.16.0.0-cp36-cp36m-win32.whl

Download URL pystan-2.16.0.0-cp36-cp36m-win32.whl
Size 32.4 MB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
0fe3e585e74acc3b25b8fe258e15a068141cdbd2011daefb2ca1bb27da6c43f8
BLAKE2b-256 checksum
How to use checksums
62bdd4bf17e31a25ad6c3091e7ef66d9744dc54429ab911d2b781121aec652ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pystan-2.16.0.0-cp36-cp36m-manylinux1_x86_64.whl

Download URL pystan-2.16.0.0-cp36-cp36m-manylinux1_x86_64.whl
Size 52.9 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
5fc7adbe920278eb3f388a42467f9430e0d3b97e4ec3db32dbcec5b30569d70d
BLAKE2b-256 checksum
How to use checksums
7187b4a3af126a07aad3a8cd155f8042a917ecfc04fad02606a705175783cc07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pystan-2.16.0.0-cp36-cp36m-manylinux1_i686.whl

Download URL pystan-2.16.0.0-cp36-cp36m-manylinux1_i686.whl
Size 52.1 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
b15478f7e73c37cfba5e6fafe73c64adb8f865b3d6b858f5a48be819fcca2727
BLAKE2b-256 checksum
How to use checksums
198038397de73ca38a8f84d06db63538ccd967e79c24b3a4f995531da336ae9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / 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

Download URL 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
Size 34.6 MB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.10+ Intel (x86-64, i386) macOS 10.10+ x86-64 macOS 10.6+ Intel (x86-64, i386) macOS 10.9+ Intel (x86-64, i386) macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
89dd0975af5d150df5057c858a5d20b38a60dadb85f2d2204474c445a643ec09
BLAKE2b-256 checksum
How to use checksums
9a3f8da67e31a500489fb94e55b704acbd72591179817cb8e195c8646faebaf8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pystan-2.16.0.0-cp35-cp35m-win_amd64.whl

Download URL pystan-2.16.0.0-cp35-cp35m-win_amd64.whl
Size 32.5 MB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
3f826bf9830d48ebf49913ab41a6af5edc08bce88b3a118029ee72d3e2ee4d43
BLAKE2b-256 checksum
How to use checksums
2e0e3b50ac69bafdd26820fc6842662cfd9dbb7e9e64ee0a53144cbfabca1f49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pystan-2.16.0.0-cp35-cp35m-win32.whl

Download URL pystan-2.16.0.0-cp35-cp35m-win32.whl
Size 32.4 MB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
c4b70c476fe4accd8560feed544f8bb09bd9f69d0109a732c80184c6c6cc9721
BLAKE2b-256 checksum
How to use checksums
a03f4b84dcb67f6e4e9facb43f9eda5358b72712ec18e65ff13466223d6b4ff7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pystan-2.16.0.0-cp35-cp35m-manylinux1_x86_64.whl

Download URL pystan-2.16.0.0-cp35-cp35m-manylinux1_x86_64.whl
Size 52.9 MB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
889de550e63ba37c0dd1bb01a4fd13a71fa6a13337681dd6912bb7764adab78f
BLAKE2b-256 checksum
How to use checksums
11490d735266c4cb5c30e9df3e9be274c5dba0bd07c894cabe42e359599cc00a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pystan-2.16.0.0-cp35-cp35m-manylinux1_i686.whl

Download URL pystan-2.16.0.0-cp35-cp35m-manylinux1_i686.whl
Size 52.1 MB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
8709332af2310dcb76a7f055900c3375fa64f5365ce490f40c651fb4b563c214
BLAKE2b-256 checksum
How to use checksums
1164e74f973e95b910dcfbdd36b70c0af547f82955c180a82cfc7f484fbf7370
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / 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

Download URL 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
Size 34.6 MB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.10+ Intel (x86-64, i386) macOS 10.10+ x86-64 macOS 10.6+ Intel (x86-64, i386) macOS 10.9+ Intel (x86-64, i386) macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
979d7a97fc334ea498f97f05be16b9feaa7d9317b65b1d7847ae1421d407834a
BLAKE2b-256 checksum
How to use checksums
cfd1b7e618e63e4bd8a0aad75ae018115a1e0a17237bf67316624fcad53381b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pystan-2.16.0.0-cp34-cp34m-manylinux1_x86_64.whl

Download URL pystan-2.16.0.0-cp34-cp34m-manylinux1_x86_64.whl
Size 52.9 MB
Tags CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
aeaf41f4abf8e320a5d3ab54972bad8e74fbac1ea8dd62507d981b18d173936a
BLAKE2b-256 checksum
How to use checksums
573d7bd1df0b321323d9047e18c68028e841a912551157cfcbb8f75d5983e603
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pystan-2.16.0.0-cp34-cp34m-manylinux1_i686.whl

Download URL pystan-2.16.0.0-cp34-cp34m-manylinux1_i686.whl
Size 52.1 MB
Tags CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
214bb1046ce5a002455c77619b583fab556c33cb24f714171eb0edc6e184723f
BLAKE2b-256 checksum
How to use checksums
d91898f8d95436c7777f65975969d77e7c6f78690960f28a22c1a53ed504edb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / 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

Download URL 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
Size 34.6 MB
Tags CPython 3.4 CPython 3.4 pymalloc macOS 10.10+ Intel (x86-64, i386) macOS 10.10+ x86-64 macOS 10.6+ Intel (x86-64, i386) macOS 10.9+ Intel (x86-64, i386) macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
8f40b79a6acb871fe9672bdac7dfca588b6ea0506c48b633895488e36c44ba95
BLAKE2b-256 checksum
How to use checksums
eda82fb975c924c311d75390224353da3921370c2c233fcf91b4723bcc4375ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pystan-2.16.0.0-cp27-cp27mu-manylinux1_x86_64.whl

Download URL pystan-2.16.0.0-cp27-cp27mu-manylinux1_x86_64.whl
Size 52.9 MB
Tags CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
bea7da71cf60a10969b0c3527f3eed9bc26849ed93077ce46f773999b8fa71f1
BLAKE2b-256 checksum
How to use checksums
d0d6cb96a18bc3c59869586ee7a4449b16da528ed3274a49c098c169ea0bb666
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pystan-2.16.0.0-cp27-cp27mu-manylinux1_i686.whl

Download URL pystan-2.16.0.0-cp27-cp27mu-manylinux1_i686.whl
Size 52.1 MB
Tags CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
2307bacbb3b41a6a659ac11c895e26dfdc9ab8e3669cb0650a3948ba8c88b845
BLAKE2b-256 checksum
How to use checksums
066a95daaa273a0dffd9ba9ba11c84eff2e96e2e142a1fd84300e7ace2c22483
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pystan-2.16.0.0-cp27-cp27m-manylinux1_x86_64.whl

Download URL pystan-2.16.0.0-cp27-cp27m-manylinux1_x86_64.whl
Size 52.9 MB
Tags CPython 2.7 CPython 2.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
41100e2b7b1a93b7f34ee8aaf2cfbbc2b5d319b46434cd0862d8e661283c9d78
BLAKE2b-256 checksum
How to use checksums
dc62a805ac114097f101c0d6150f22cc8701a61295cd46671e10529f60367227
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pystan-2.16.0.0-cp27-cp27m-manylinux1_i686.whl

Download URL pystan-2.16.0.0-cp27-cp27m-manylinux1_i686.whl
Size 52.1 MB
Tags CPython 2.7 CPython 2.7 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
80dc6fd8e8ae037402a3b8c499ceb523fe92782b91ab985cf4b42ccacd33c090
BLAKE2b-256 checksum
How to use checksums
52566b6dce9e5a888f4fbcb1ab702f83524f6ae5937f988ce1a83cc076e4859f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / 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

Download URL 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
Size 34.6 MB
Tags CPython 2.7 CPython 2.7 pymalloc macOS 10.10+ Intel (x86-64, i386) macOS 10.10+ x86-64 macOS 10.6+ Intel (x86-64, i386) macOS 10.9+ Intel (x86-64, i386) macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
27025541a1a7ff5455aac15ac7e2be815d8663ceab584a8d72863390b7ca355c
BLAKE2b-256 checksum
How to use checksums
06ef9cd515af82123aefafbd4a0bfb371dfb7e01d1f8f1b6d66aadd1cd1c64ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

3.14.0

2 release files

3.10.1

2 release files

3.9.1

2 release files

3.9.0

2 release files

3.8.0

2 release files

3.7.0

2 release files

3.6.0

2 release files

3.5.0

2 release files

3.4.0

2 release files

3.3.0

2 release files

3.2.0

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.2

2 release files

3.0.1

2 release files

3.0.0

2 release files

This release

2.16.0.0 This release

19 release files

2.7.0.0

1 release file

2.4.0.0

1 release file

2.3.0.0

1 release file

2.2.0.1

1 release file

2.2.0.0

1 release file

2.1.0.1

1 release file

2.1.0.0

1 release file

2.0.1.3

1 release file

2.0.1.1

1 release file

2.0.1.0

1 release file

2.0.0.1

1 release file

2.0.0.0

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page