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 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.12.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distributions (sdists)

Source distribution for pystan 2.12.0.0
File Size Uploaded
pystan-2.12.0.0.zip 31.4 MB Details
pystan-2.12.0.0.tar.gz 16.8 MB Details

Built distributions (wheels)

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

Total release size: 717.3 MB

Release files / pystan-2.12.0.0.zip

Download URL pystan-2.12.0.0.zip
Size 31.4 MB
Tags Source
SHA-256 checksum
How to use checksums
8abe9e4fc24054a25eb636ce7c36222dd1b244f8b4482d96f1e4858106db0cd3
BLAKE2b-256 checksum
How to use checksums
321a16411ac9326daddde32e1ef1602561593e83709b6302e29ee6c3ff5a898b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pystan-2.12.0.0.tar.gz

Download URL pystan-2.12.0.0.tar.gz
Size 16.8 MB
Tags Source
SHA-256 checksum
How to use checksums
7cfeb8694f94e638eff1e625275479336a799610b0940e2eb1fa0ee97bcad0ef
BLAKE2b-256 checksum
How to use checksums
0f3a795bb3e8d94f646fb7740436da2b20848c9bc78d30072c2871ea028c0ee2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL pystan-2.12.0.0-cp35-cp35m-win_amd64.whl
Size 39.2 MB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
193e0fe99ac4c2d5231328b63c045f19e6737b99fb3455e61b95aabed5820502
BLAKE2b-256 checksum
How to use checksums
c069c125dc23721e7aa6246a8506e428824cea4370dfeee75cad1dacde649ccc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

Download URL pystan-2.12.0.0-cp35-cp35m-win32.whl
Size 39.1 MB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
36122b34e1a4b658d5d2bea546363ab09f698ef21a096f999e5decd8965bf148
BLAKE2b-256 checksum
How to use checksums
53d306498c2ce5dc0e537842904a75ceb3fbc997114714012947efdcd6a2e49f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

Download URL pystan-2.12.0.0-cp35-cp35m-manylinux1_i686.whl
Size 58.1 MB
Tags CPython 3.5 CPython 3.5 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
2344041dc2001c265323d2bda6b55a6d98abbed012f1488a369ab03b0d057a2e
BLAKE2b-256 checksum
How to use checksums
564c7f113efc82b47141a9d329b262cca8619cd9a6f35d78d977b5d051d43bcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pystan-2.12.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.12.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 41.3 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
770676f95d24a38c5421f0750800fd126c46b3a1adb76ef7b2adbadb4314fdee
BLAKE2b-256 checksum
How to use checksums
76d38408a8d458c6313ba7e89da8af9b8b6cf24ecbc1cb1d6ab95b9c7b0f3f3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

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

Release files / pystan-2.12.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.12.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 41.3 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
615932179ad0427bebaed545dd62021e22ce22fab2defaeeaefa4dbf72fd46bd
BLAKE2b-256 checksum
How to use checksums
4ba1402063de54cb357ccfa7571bfae5b236c7607b036e9e7889b41f80dbb0ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

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

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

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

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

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

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

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

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

Release files / pystan-2.12.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.12.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 41.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
9b673c7f0c48213b38ce7215a532fa859b6272de992afa9f8013233cae9f89ed
BLAKE2b-256 checksum
How to use checksums
c4d7ff719365fdb2f64314b22ed4d5e030ae1c5083377ba327137acf0ee455db
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.12.0.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