Skip to main content

PyStan: The Python Interface to Stan

Stan logo

pypi version travis-ci build status appveyor-ci build status

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]}

fit = pystan.stan(model_code=schools_code, 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.14.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.14.0.0
File Size Uploaded
pystan-2.14.0.0.tar.gz 18.4 MB Details

Built distributions (wheels)

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

Total release size: 898.6 MB

Release files / pystan-2.14.0.0.tar.gz

Download URL pystan-2.14.0.0.tar.gz
Size 18.4 MB
Tags Source
SHA-256 checksum
How to use checksums
3bed255ca7d35bbd4ed0d5f30470744d9a71b06c1fa8b88281053dd430b0b1b2
BLAKE2b-256 checksum
How to use checksums
799651a8857564e68f92ee33b2c53baee5435fcd5569dd9778f3e0efc67dae6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL pystan-2.14.0.0-cp36-cp36m-manylinux1_x86_64.whl
Size 62.2 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
17d819da2b3303ecc329ab81c18e0b3e4906a1d02009daaf2a34d3c4613f6c1a
BLAKE2b-256 checksum
How to use checksums
02bd8ec85d7c0bc6db429006ffaf92f5515c2cf7487c13d5178e4831bab0b447
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

Release files / pystan-2.14.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.14.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 44.4 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
734e6945a21d86c309e7ae06e57d980af6bd7d965c076ad162458d7b1a4c6f5e
BLAKE2b-256 checksum
How to use checksums
ea1338beec6f7a311725dcac2f8eb5ecca733312d43c67e4a2baecde03ba3c5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL pystan-2.14.0.0-cp35-cp35m-win_amd64.whl
Size 42.3 MB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
75799e3db4da90594e554040ef80059267eafda90b17dd08856f52e8acb0a57a
BLAKE2b-256 checksum
How to use checksums
b141375fe0f09480e8308f97a138ca37ac7cbb0ce37595c38ab319c3e308b59b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

Download URL pystan-2.14.0.0-cp35-cp35m-manylinux1_x86_64.whl
Size 62.2 MB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
357fc266efd8135938830920a97a12113a20e28045c6a86d1908916d27b5fa0e
BLAKE2b-256 checksum
How to use checksums
ec7cdce3326c4c47c7b25bd09f0e2d13938fe9be71932920e225978928e9dfd5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

Release files / pystan-2.14.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.14.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 44.4 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
c7b0cb1cdc1fdf76d44a7dfddc393afa5e51d3928f7a39103ede60e7bde39834
BLAKE2b-256 checksum
How to use checksums
44927a48eb7a093bdcb1ecbda1703a344d54373a8e84fe57f9dc7c2ec14d202d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

Download URL pystan-2.14.0.0-cp34-cp34m-manylinux1_i686.whl
Size 61.4 MB
Tags CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
8f662640f413423b92c60d8a6d8f4efc42df94ecc2bd4e7ae9b7cb63027743bb
BLAKE2b-256 checksum
How to use checksums
9acba05a8b1b245ec91b8aab06b2a4ba5c4478f4b61bd2f46f3c2d6780b881bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pystan-2.14.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.14.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 44.4 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
ace764b58cd4b64379be220b4371f0a271576c4f5789f9930af1e88fe9a820b1
BLAKE2b-256 checksum
How to use checksums
d432eea8916c1407a348c1bdf835698ede947f5d5d1569949cba70300342b0ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

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

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

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

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

Download URL pystan-2.14.0.0-cp27-cp27m-manylinux1_i686.whl
Size 61.4 MB
Tags CPython 2.7 CPython 2.7 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
87ab9ba4530257fcaff05824cc36ec5bd2ae33be2fd3f2a8484c25e84db6e5c4
BLAKE2b-256 checksum
How to use checksums
876876893f851461c61770aaeaf5d1f1f0d6483d8f9cd9be05b6198f8bd391d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pystan-2.14.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.14.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 44.4 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
1b7d4dedc73acf278bf8c017c95ff7dd3b58d66252719e9b19fd62acb1ae849e
BLAKE2b-256 checksum
How to use checksums
4986d3bb601ee10de16314f9566afc09d49bb8deffba16dea79b7d212114fe4a
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.14.0.0 This release

17 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