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.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.17.1.0
File Size Uploaded
pystan-2.17.1.0.tar.gz 13.9 MB Details

Built distributions (wheels)

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

Total release size: 1.0 GB

Release files / pystan-2.17.1.0.tar.gz

Download URL pystan-2.17.1.0.tar.gz
Size 13.9 MB
Tags Source
SHA-256 checksum
How to use checksums
d4f91b5300c002448c4141abb806264f929fffed4fb72b9dbdfd2def83529b78
BLAKE2b-256 checksum
How to use checksums
4069259304776a6fca45b70e1577c184c2ef6de00630be2e26cd5d5a63581fb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

Download URL pystan-2.17.1.0-cp36-cp36m-win32.whl
Size 45.3 MB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
180292d5fa150c09346bccfa7136709164bbe1584c0bb925e7cda94fb0f1a08c
BLAKE2b-256 checksum
How to use checksums
8edcb7d21c895e8c171fc781a810967fb7be7c08f1d4b305829890b4461838b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL pystan-2.17.1.0-cp36-cp36m-manylinux1_x86_64.whl
Size 68.1 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
606f02f80bd50722b0e07717417a9190af95abe47f22d05998d7076a832f3fe1
BLAKE2b-256 checksum
How to use checksums
4637801a5a932e7f1f038542e7c5e4c4010aac19a26ea6bde9534505465f8c8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

Release files / pystan-2.17.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.17.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 48.0 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
438c4773760a1e8b48dc266bb58c8a808de79a56beb80751050e679b4c72dc9e
BLAKE2b-256 checksum
How to use checksums
b33cdce0eae3f03bae8fc9af88e2dc12526081b53e4889a387f550d4daefe8db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL pystan-2.17.1.0-cp35-cp35m-win_amd64.whl
Size 45.5 MB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
836a0ca5e99d9ebeaa75a16d389f726e16aba2bc1dc6558db470272f4c1d366a
BLAKE2b-256 checksum
How to use checksums
9a0fb76ab727cc1e58b4102aff1ffc6b5dfa45428135bda410393c91b0503d66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

Download URL pystan-2.17.1.0-cp35-cp35m-manylinux1_x86_64.whl
Size 68.1 MB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
9d0cb6a80f884570a655ff7cbee1ae80f6e47469ea660a660770c397a4b9bb49
BLAKE2b-256 checksum
How to use checksums
96621b9e1d0a4ce73f1f649c2d1370c1bc33a4933c127716490528ca3bfc043d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL pystan-2.17.1.0-cp35-cp35m-manylinux1_i686.whl
Size 67.2 MB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
0005fe4eb3131f07c3741b05a2cdf3d1e419ef476ff57fe945a6bf9d5de80c40
BLAKE2b-256 checksum
How to use checksums
1e1ac88a3f3b46d13d77d512e8452c88b2569bd7bd63ee1a1c1f09231b720274
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pystan-2.17.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.17.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 48.0 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
3a034db3e176ea2cf2c61b10c425b26636220e700dc406fef3b1fad16d8b209a
BLAKE2b-256 checksum
How to use checksums
13492f13ee2ba2f6ff4691378886921f9ccd22c23682c81b96447b2df802b511
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

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

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

Download URL pystan-2.17.1.0-cp27-cp27mu-manylinux1_x86_64.whl
Size 68.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
d856eeae100a499e69840c26d75d511a98b564f21efc8d7f9431846dc7fcfee9
BLAKE2b-256 checksum
How to use checksums
9f130bb28e764406b3f184eff37bbdb6d3749a48fdf70634df0db1ef8dee7664
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL pystan-2.17.1.0-cp27-cp27mu-manylinux1_i686.whl
Size 67.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
bdaf04bb7b617c2efd66e0c980a3552219f0fdbd67016eaa11989458d06242d3
BLAKE2b-256 checksum
How to use checksums
5d46dc1fbdf1d4781245ed6379250bf7dbd9f1c121a1c25927435ee5eea632de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL pystan-2.17.1.0-cp27-cp27m-manylinux1_x86_64.whl
Size 68.1 MB
Tags CPython 2.7 CPython 2.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
882b8f137ee1f4daa6fab0821acd6de4c403e9ef7dc4f213a935153ffe76ce3c
BLAKE2b-256 checksum
How to use checksums
770ffc5abd1b34789ad38fb6c72c674f9001a587c0b4b91c300f16c2e20dc3dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

Release files / pystan-2.17.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.17.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 48.0 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
90e6fecd6f33530f09294db25d0ce9f1bc7527334084bb5cb81289b24f2c8cf8
BLAKE2b-256 checksum
How to use checksums
96d033e70212ea5c8eb305671079247b098c75ad0188919941fa5f50dd53756e
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.1.0 This release

18 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