PyStan: The Python Interface to Stan
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/.
Important links
HTML documentation: https://pystan.readthedocs.org
Issue tracker: https://github.com/stan-dev/pystan/issues
Source code repository: https://github.com/stan-dev/pystan
Stan: http://mc-stan.org/
Stan User’s Guide and Reference Manual (pdf) available at http://mc-stan.org
Similar projects
Detailed Installation Instructions
Detailed installation instructions can be found in the 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.10.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pystan-2.10.0.0.tar.gz | 16.7 MB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| pystan-2.10.0.0-cp35-cp35m-win_amd64.whl | CPython 3.5 | CPython 3.5 pymalloc | Windows x86-64 | Details |
| pystan-2.10.0.0-cp35-cp35m-win32.whl | CPython 3.5 | CPython 3.5 pymalloc | Windows x86-32 | Details |
| pystan-2.10.0.0-cp35-cp35m-manylinux1_x86_64.whl | CPython 3.5 | CPython 3.5 pymalloc | Linux glibc 2.5+ x86-64 | Details |
| pystan-2.10.0.0-cp35-cp35m-manylinux1_i686.whl | CPython 3.5 | CPython 3.5 pymalloc | Linux glibc 2.5+ x86-32 | Details |
| pystan-2.10.0.0-cp34-cp34m-manylinux1_x86_64.whl | CPython 3.4 | CPython 3.4 pymalloc | Linux glibc 2.5+ x86-64 | Details |
| pystan-2.10.0.0-cp34-cp34m-manylinux1_i686.whl | CPython 3.4 | CPython 3.4 pymalloc | Linux glibc 2.5+ x86-32 | Details |
| pystan-2.10.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.6+ Intel (x86-64, i386), macOS 10.10+ Intel (x86-64, i386) | Details |
| pystan-2.10.0.0-cp33-cp33m-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.3 | CPython 3.3 pymalloc | macOS 10.9+ Intel (x86-64, i386), macOS 10.10+ x86-64, macOS 10.9+ x86-64, macOS 10.6+ Intel (x86-64, i386), macOS 10.10+ Intel (x86-64, i386) | Details |
| pystan-2.10.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.10.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.10.0.0-cp27-cp27m-manylinux1_x86_64.whl | CPython 2.7 | CPython 2.7 pymalloc | Linux glibc 2.5+ x86-64 | Details |
| pystan-2.10.0.0-cp27-cp27m-manylinux1_i686.whl | CPython 2.7 | CPython 2.7 pymalloc | Linux glibc 2.5+ x86-32 | Details |
| pystan-2.10.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: 833.1 MB
Release files / pystan-2.10.0.0.tar.gz
| Download URL | pystan-2.10.0.0.tar.gz |
|---|---|
| Size | 16.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8156cb0e3d9a74c489eabb2915b32f3f219e450c31ee0c5d6dc8e3e8ce59de77
|
|
BLAKE2b-256 checksum How to use checksums |
3edf015807edf4a0501aadebce7891eeaa08f2fdfa16ac5e382e07778cc59d42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pystan-2.10.0.0-cp35-cp35m-win_amd64.whl
| Download URL | pystan-2.10.0.0-cp35-cp35m-win_amd64.whl |
|---|---|
| Size | 38.6 MB |
| Tags | CPython 3.5 CPython 3.5 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6cf8d2839290d9a0c89a5dd2be24bef67d73b87ed425173b042c54edeb3f0186
|
|
BLAKE2b-256 checksum How to use checksums |
d676202177a2eb3a1fc178e15e6971a576dfa81565304cd867054da6f4dd3e55
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pystan-2.10.0.0-cp35-cp35m-win32.whl
| Download URL | pystan-2.10.0.0-cp35-cp35m-win32.whl |
|---|---|
| Size | 38.5 MB |
| Tags | CPython 3.5 CPython 3.5 pymalloc Windows x86-32 |
|
SHA-256 checksum How to use checksums |
90126d5468155f55a6cfcdb52b8c683729d61f9270207466fc57511c1d579902
|
|
BLAKE2b-256 checksum How to use checksums |
1ec10aa23a4e19088794110905938e08e113cb81d6c9bb0ccdd9b18550d19892
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pystan-2.10.0.0-cp35-cp35m-manylinux1_x86_64.whl
| Download URL | pystan-2.10.0.0-cp35-cp35m-manylinux1_x86_64.whl |
|---|---|
| Size | 69.9 MB |
| Tags | CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
ed71bc441f3d344ee9894a3ecfa041008d08cda16a684d682c4403f0df53b470
|
|
BLAKE2b-256 checksum How to use checksums |
cdbf57022acec73ad3e2855c83185e6918b66f322bd4c86beded20ee6336f382
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pystan-2.10.0.0-cp35-cp35m-manylinux1_i686.whl
| Download URL | pystan-2.10.0.0-cp35-cp35m-manylinux1_i686.whl |
|---|---|
| Size | 69.7 MB |
| Tags | CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32 |
|
SHA-256 checksum How to use checksums |
6163fed1b8fdd88b12c214d6578f522ae03a330a6e622a61060f1c0677ce4658
|
|
BLAKE2b-256 checksum How to use checksums |
e76b8ec40ad5fccf9feeb76825278b707cfea17790f07d424bc479457f35eb2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pystan-2.10.0.0-cp34-cp34m-manylinux1_x86_64.whl
| Download URL | pystan-2.10.0.0-cp34-cp34m-manylinux1_x86_64.whl |
|---|---|
| Size | 69.9 MB |
| Tags | CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
e6535cefa1a6698408a20b6308431d598d6ad3d129497191da641e15f70c96ea
|
|
BLAKE2b-256 checksum How to use checksums |
e0891ffd526c707d7c9a1192e94b7d5b1c72b54a4e3948d1a23c417da6c631c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pystan-2.10.0.0-cp34-cp34m-manylinux1_i686.whl
| Download URL | pystan-2.10.0.0-cp34-cp34m-manylinux1_i686.whl |
|---|---|
| Size | 69.7 MB |
| Tags | CPython 3.4 CPython 3.4 pymalloc Linux glibc 2.5+ x86-32 |
|
SHA-256 checksum How to use checksums |
7a863b589faa26d5b91cfa15f6d99d9ed0288529992389ab5f24359dfb108507
|
|
BLAKE2b-256 checksum How to use checksums |
9d04abca713e0ef159dfda07cce36dc5317598c614270fcf89e865cc72a0bea0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pystan-2.10.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.10.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 | 60.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 |
35778405a49b6636c23ecd01bc37e8f0833de83aa272fc6c1517cbde099a8ddf
|
|
BLAKE2b-256 checksum How to use checksums |
dee62b41725128562d03a67d100a4bbe7af0dac3cc9463a444f45bb2f8a5c977
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pystan-2.10.0.0-cp33-cp33m-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.10.0.0-cp33-cp33m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl |
|---|---|
| Size | 60.3 MB |
| Tags | CPython 3.3 CPython 3.3 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 |
e589b2041f99b67dffc3aace8c3dd1316d9f65097910f709c86443393aeb5c0c
|
|
BLAKE2b-256 checksum How to use checksums |
d8ea66d05db606e49fcd5938f68e59b1c91928b3047c1f90ef11490e20392962
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pystan-2.10.0.0-cp27-cp27mu-manylinux1_x86_64.whl
| Download URL | pystan-2.10.0.0-cp27-cp27mu-manylinux1_x86_64.whl |
|---|---|
| Size | 69.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 |
5753263050b3221df39a0b099b0e03a275e86a93123bceeb843b1a76298ad6fb
|
|
BLAKE2b-256 checksum How to use checksums |
039e40394a6625ffca6def383a22eb951b844d5176085c838138076aec33ef7a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pystan-2.10.0.0-cp27-cp27mu-manylinux1_i686.whl
| Download URL | pystan-2.10.0.0-cp27-cp27mu-manylinux1_i686.whl |
|---|---|
| Size | 69.6 MB |
| Tags | CPython 2.7 CPython 2.7 pymalloc wide-unicode Linux glibc 2.5+ x86-32 |
|
SHA-256 checksum How to use checksums |
0fb888f8ab1b1a03820f8dcd4aa9fb3e641be8a593ad61385f670a01bcbe0f03
|
|
BLAKE2b-256 checksum How to use checksums |
1e6ad42098de648fc82f1d39a8582d384f510628b23db1b13e6d71d45557f4ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pystan-2.10.0.0-cp27-cp27m-manylinux1_x86_64.whl
| Download URL | pystan-2.10.0.0-cp27-cp27m-manylinux1_x86_64.whl |
|---|---|
| Size | 69.9 MB |
| Tags | CPython 2.7 CPython 2.7 pymalloc Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
0270c2a732de6f78c67fbba0cba07a3f4cc38f20a3bc70d551b1d2237477298a
|
|
BLAKE2b-256 checksum How to use checksums |
9b9157b7ba7c2f4c4561962e8c9236526e02f22f8575a91db03698dc511b5f3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pystan-2.10.0.0-cp27-cp27m-manylinux1_i686.whl
| Download URL | pystan-2.10.0.0-cp27-cp27m-manylinux1_i686.whl |
|---|---|
| Size | 69.6 MB |
| Tags | CPython 2.7 CPython 2.7 pymalloc Linux glibc 2.5+ x86-32 |
|
SHA-256 checksum How to use checksums |
31ea5dd793a96b2b275e32f17798ae7509bc8624979646a63fe3c4cfd4b35f95
|
|
BLAKE2b-256 checksum How to use checksums |
86608bf6cc949dad28a12601cf5c460f9ff1e22b77378340f5d1f993f391c62f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pystan-2.10.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.10.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 | 60.3 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 |
50a0ba88c05755a27992fcc7acae8cfec3ccc1b87cd178103579a1161f13d2cf
|
|
BLAKE2b-256 checksum How to use checksums |
71ff6c68e289aab44a6354e2d4152efd592360abd7dc7a6b24193b9eda67c51f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |