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.17.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.17.0.0
File Size Uploaded
pystan-2.17.0.0.tar.gz 13.9 MB Details

Built distributions (wheels)

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

Total release size: 833.2 MB

Release files / pystan-2.17.0.0.tar.gz

Download URL pystan-2.17.0.0.tar.gz
Size 13.9 MB
Tags Source
SHA-256 checksum
How to use checksums
27289d5c0eab1c1427d2fe3fd94b527161433fb8b039bf094ad4d73ebb595e49
BLAKE2b-256 checksum
How to use checksums
2b4e79c20fd10e8e93cc2b1d95cb970c96dcf3aeae8682ecfc78e2011d3ad554
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

Download URL pystan-2.17.0.0-cp36-cp36m-win32.whl
Size 32.9 MB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
6c807a4a0a787f4adad834895d059e4678acc03f7e38a361e13fb941d54483fe
BLAKE2b-256 checksum
How to use checksums
4ad42d6dff5b4d679a5c9e277b25b1cbe7a5a22ac498bd28c2606fe498522b8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL pystan-2.17.0.0-cp36-cp36m-manylinux1_x86_64.whl
Size 55.1 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
2d8930df612153d0db20eca4bac2a6b937f23e963fd68c918757949138f1e51e
BLAKE2b-256 checksum
How to use checksums
d08f2bd43935109a06729a14dd427b70972bb19051667bece30febdc610f2880
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

Download URL 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
Size 35.2 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
7d8743882fb75ae27dbd39c4665cd2c506eae6493ec09be9267e054859b32be7
BLAKE2b-256 checksum
How to use checksums
88ed81f9b7d3ae65a2fc6a63115fc88e9d5d50eef442748c977b3ffcff063c10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL pystan-2.17.0.0-cp35-cp35m-win_amd64.whl
Size 33.0 MB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
e0260a8794573e643b94c207a0a8c86fca39310cfa0fcadd15d7a57b2e4a7ddd
BLAKE2b-256 checksum
How to use checksums
0aed3aae53e1f37c8a63d55568acca0842fc26c5ffab78032e5b26b722e0ea67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

Download URL pystan-2.17.0.0-cp35-cp35m-manylinux1_x86_64.whl
Size 55.1 MB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
0a219ebddc66db5e8dd8964d67ffcb342b153177c521e761acafcd58c55bd58f
BLAKE2b-256 checksum
How to use checksums
112798c4a4b401dbb7728ff5b5b491f18bbe5f9e1ba779dc54cc0d5cd9a35621
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL pystan-2.17.0.0-cp35-cp35m-manylinux1_i686.whl
Size 54.2 MB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
986a066adedbfb92444f32c3dcbfa8851bee2200a881c37f9070a6c4acde723b
BLAKE2b-256 checksum
How to use checksums
c66840ee1a863c5e1fe058d820550021789225f60cb0beb583907b94b2cb0966
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL 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
Size 35.2 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
440cf5309e8b921d6e2db64efc2d49d4c6d8fd98a3cb1c15203f0ca420ff1e2e
BLAKE2b-256 checksum
How to use checksums
0d5f1890618b6383251a7ea17843a2d296e427fffbe1753a574db4caadef087d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

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

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

Download URL 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
Size 35.2 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
94c3efacff56819ce56fb3ac1a2bd6f6830e1b6c068bc8ed9464c47144e78402
BLAKE2b-256 checksum
How to use checksums
df45f7c74a34428910370e8f8b1a694bb6727bada1327a95d5db443053abf105
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

Download URL pystan-2.17.0.0-cp27-cp27mu-manylinux1_i686.whl
Size 54.2 MB
Tags CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
48a411a9d45e7822ea89cd9acad47709a1aca2db56c0d43c71f2e378d4c1afe6
BLAKE2b-256 checksum
How to use checksums
db548e66692d1fde7e3e77111277be5cb0ece7c9fa3c9781443b46694ef91da1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL pystan-2.17.0.0-cp27-cp27m-manylinux1_x86_64.whl
Size 55.1 MB
Tags CPython 2.7 CPython 2.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
06320a32c97b504aeca405d2b3d0171346668ce461433e678a3c120a85a24bea
BLAKE2b-256 checksum
How to use checksums
0a11db66e17e6ac72478357c0de10d214dd999ea579a924ef0846c38876398ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL pystan-2.17.0.0-cp27-cp27m-manylinux1_i686.whl
Size 54.2 MB
Tags CPython 2.7 CPython 2.7 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
751d546aeaff62789c21112ddacd33e2f0c8826258fdf390273f9aea768dcbca
BLAKE2b-256 checksum
How to use checksums
551b3922d0f20ce27732477f09fd232c9fd16f255c099aecc67dc92d53cb7863
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL 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
Size 35.2 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
e329a107ef6d0cbb619e7b174513f155739a1b7ce1f5a46c040e725da5fa4e3f
BLAKE2b-256 checksum
How to use checksums
aad1d156e6e1726e6602fe9dbe19eb352cf69bdc18f08a49fdb65e91725cac38
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.17.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