Skip to main content
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 (Linux and macOS)

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.18.1.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.18.1.0
File Size Uploaded
pystan-2.18.1.0.tar.gz 17.5 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for pystan 2.18.1.0
File
pystan-2.18.1.0-cp37-cp37m-manylinux1_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 Details
pystan-2.18.1.0-cp37-cp37m-manylinux1_i686.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-32 Details
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 CPython 3.7 CPython 3.7 pymalloc macOS 10.10+ Intel (x86-64, i386), macOS 10.9+ x86-64, macOS 10.6+ Intel (x86-64, i386), macOS 10.10+ x86-64, macOS 10.9+ Intel (x86-64, i386) Details
pystan-2.18.1.0-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details
pystan-2.18.1.0-cp36-cp36m-manylinux1_i686.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32 Details
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 CPython 3.6 CPython 3.6 pymalloc macOS 10.10+ Intel (x86-64, i386), macOS 10.9+ x86-64, macOS 10.6+ Intel (x86-64, i386), macOS 10.10+ x86-64, macOS 10.9+ Intel (x86-64, i386) Details
pystan-2.18.1.0-cp35-cp35m-manylinux1_x86_64.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 Details
pystan-2.18.1.0-cp35-cp35m-manylinux1_i686.whl CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32 Details
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 CPython 3.5 CPython 3.5 pymalloc macOS 10.10+ Intel (x86-64, i386), macOS 10.9+ Intel (x86-64, i386), macOS 10.9+ x86-64, macOS 10.6+ Intel (x86-64, i386), macOS 10.10+ x86-64 Details
pystan-2.18.1.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.18.1.0-cp27-cp27mu-manylinux1_i686.whl CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.5+ x86-32 Details
pystan-2.18.1.0-cp27-cp27m-manylinux1_x86_64.whl CPython 2.7 CPython 2.7 pymalloc Linux glibc 2.5+ x86-64 Details
pystan-2.18.1.0-cp27-cp27m-manylinux1_i686.whl CPython 2.7 CPython 2.7 pymalloc Linux glibc 2.5+ x86-32 Details
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 CPython 2.7 CPython 2.7 pymalloc macOS 10.10+ x86-64, macOS 10.9+ x86-64, macOS 10.6+ Intel (x86-64, i386), macOS 10.10+ Intel (x86-64, i386), macOS 10.9+ Intel (x86-64, i386) Details

Total release size: 725.6 MB

Release files / pystan-2.18.1.0.tar.gz

Download URL pystan-2.18.1.0.tar.gz
Size 17.5 MB
Tags Source
SHA-256 checksum
How to use checksums
f8d50218d00848bff7cc9f33471eb5c0cf0f84af0a807963349a7931bb782b46
BLAKE2b-256 checksum
How to use checksums
96216452aadcbb5807fb8858e8789c74d62f5ebaece0351ff231f44064c44b33
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / pystan-2.18.1.0-cp37-cp37m-manylinux1_x86_64.whl

Download URL pystan-2.18.1.0-cp37-cp37m-manylinux1_x86_64.whl
Size 50.0 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
943de835e14111b620daaea5714c0928669c8df161dd36b3831e9ba3fc4c1a5c
BLAKE2b-256 checksum
How to use checksums
a5c22831ae9d73f8e2a8af1f0ed0d51abdefaeabc43cf54cce83c852388d0971
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / pystan-2.18.1.0-cp37-cp37m-manylinux1_i686.whl

Download URL pystan-2.18.1.0-cp37-cp37m-manylinux1_i686.whl
Size 50.0 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
0e6fb712a178eb9cf5ea2f3922da6fc88aad183fa948db283798559e33217522
BLAKE2b-256 checksum
How to use checksums
da0a4801521af0cdf0a635e977c9e5bc194589dd28b6cc0cb97eeb1d3c3c3431
Upload date
Uploaded using Trusted Publishing?
What is 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

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

Download URL 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
Size 52.1 MB
Tags CPython 3.7 CPython 3.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
69e326456d1e0cebe056f70fdd891309061ab121470781e1f6db70e9c384fec8
BLAKE2b-256 checksum
How to use checksums
7a9235092c4210fbbdc878e986bd75b0acdafc735771196f08f0705522ec1a5e
Upload date
Uploaded using Trusted Publishing?
What is 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

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

Download URL pystan-2.18.1.0-cp36-cp36m-manylinux1_x86_64.whl
Size 50.0 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
cc0bb600f402166c9a96857cf6f9ffba61db610eb16eedd8c01a6f1cfeb5c09c
BLAKE2b-256 checksum
How to use checksums
1777dd86797a7e7fccca117233c6d50cc171e0c2b2f5a0cd2a8d9753ee09b7be
Upload date
Uploaded using Trusted Publishing?
What is 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

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

Download URL pystan-2.18.1.0-cp36-cp36m-manylinux1_i686.whl
Size 50.0 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
d5917811afcd968618a139aaa79219f2eeb3917b773023b618524b20254e2c69
BLAKE2b-256 checksum
How to use checksums
e9429c544df978d64ccfb83756b195e2c65774c76aa5c358bfc9f602127adba3
Upload date
Uploaded using Trusted Publishing?
What is 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

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

Download URL 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
Size 52.1 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
1aedf524b50065f8321a3e4e4a70d388c478cbd1e0bd04d53285f99160a956bf
BLAKE2b-256 checksum
How to use checksums
5f494a02088c14cdec2e8c40337a819d55677dc64d564526009b08e6cb7422fd
Upload date
Uploaded using Trusted Publishing?
What is 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

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

Download URL pystan-2.18.1.0-cp35-cp35m-manylinux1_x86_64.whl
Size 50.0 MB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
b068a4451f88a9e0145d424dc495481f9f159d688966632a4b10ff608ec3ef08
BLAKE2b-256 checksum
How to use checksums
ae1f3ae727fc09aa989c8b8e9589bd7c4a8db3773a19c6c235c3add64cd82bc1
Upload date
Uploaded using Trusted Publishing?
What is 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

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

Download URL pystan-2.18.1.0-cp35-cp35m-manylinux1_i686.whl
Size 50.0 MB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
6ad4d772d0f700b56295184e314bdb1bf71ae057400ef66eba0b27e244a17bd2
BLAKE2b-256 checksum
How to use checksums
c589caafa9efc46f269718d27b3e45c99fcf51d03e89e1df8e940bbf28b53bfa
Upload date
Uploaded using Trusted Publishing?
What is 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

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

Download URL 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
Size 52.1 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
16332424fa53476dd54b83f304297607c2d3f747c0718243420a36044ba45031
BLAKE2b-256 checksum
How to use checksums
e309ea6ab8e1befaf8732cb5b850834d051040c04f0378f6b10b8a1844d82c5f
Upload date
Uploaded using Trusted Publishing?
What is 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

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

Download URL pystan-2.18.1.0-cp27-cp27mu-manylinux1_x86_64.whl
Size 50.0 MB
Tags CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
ccf8209733d662ee303282c1d066d57113eecf3d44965fcd267606e4a7bc5761
BLAKE2b-256 checksum
How to use checksums
d84368ca14d77b0e22092055f774fdae8141960f058aa9b9d2e3a412242761ee
Upload date
Uploaded using Trusted Publishing?
What is 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

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

Download URL pystan-2.18.1.0-cp27-cp27mu-manylinux1_i686.whl
Size 50.0 MB
Tags CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
71e5a9cf79b658f7959491810fcac5396c7d2df40a30f10893680f90d2cba77d
BLAKE2b-256 checksum
How to use checksums
27145a4e1f833b4c393c537d0b34bbd803b5e43703872c4a8ca6e397a22860be
Upload date
Uploaded using Trusted Publishing?
What is 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

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

Download URL pystan-2.18.1.0-cp27-cp27m-manylinux1_x86_64.whl
Size 50.0 MB
Tags CPython 2.7 CPython 2.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
c316579ae0451812bca5841783aefd91a5769393170e646d3b2773406eccfa31
BLAKE2b-256 checksum
How to use checksums
db80e05f2aaee94584aa47e52a0f41fe91933699a793836e11482b4bb1c10360
Upload date
Uploaded using Trusted Publishing?
What is 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

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

Download URL pystan-2.18.1.0-cp27-cp27m-manylinux1_i686.whl
Size 50.0 MB
Tags CPython 2.7 CPython 2.7 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
bec17a2e5529900761ea91adb5c3fc2a70637d200fbd238a2e3e6df17b5685fb
BLAKE2b-256 checksum
How to use checksums
99f2cd9d22688f817d44c67c814ff0dad8fae881e5bfa9a73e7284a67478a787
Upload date
Uploaded using Trusted Publishing?
What is 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

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

Download URL 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
Size 52.1 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
33b6fdfa23fc94653f366204e87c418b0a837739a842533ac31e69aface705a5
BLAKE2b-256 checksum
How to use checksums
23bef3afa44f9309c59d49c22ae2b908dc7dfb93fec967f89595adbeb7adec54
Upload date
Uploaded using Trusted Publishing?
What is 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

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.18.1.0 This release

15 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