Skip to main content

Python interface to Stan, a package for Bayesian inference

Project description

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()

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pystan-2.15.0.0.tar.gz (25.4 MB view details)

Uploaded Source

Built Distributions

pystan-2.15.0.0-cp36-cp36m-win_amd64.whl (42.1 MB view details)

Uploaded CPython 3.6m Windows x86-64

pystan-2.15.0.0-cp36-cp36m-win32.whl (42.0 MB view details)

Uploaded CPython 3.6m Windows x86

pystan-2.15.0.0-cp36-cp36m-manylinux1_x86_64.whl (62.4 MB view details)

Uploaded CPython 3.6m

pystan-2.15.0.0-cp36-cp36m-manylinux1_i686.whl (61.6 MB view details)

Uploaded CPython 3.6m

pystan-2.15.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 (44.2 MB view details)

Uploaded CPython 3.6m macOS 10.10+ intel macOS 10.10+ x86-64 macOS 10.6+ intel macOS 10.9+ intel macOS 10.9+ x86-64

pystan-2.15.0.0-cp35-cp35m-win_amd64.whl (42.1 MB view details)

Uploaded CPython 3.5m Windows x86-64

pystan-2.15.0.0-cp35-cp35m-win32.whl (42.0 MB view details)

Uploaded CPython 3.5m Windows x86

pystan-2.15.0.0-cp35-cp35m-manylinux1_x86_64.whl (62.4 MB view details)

Uploaded CPython 3.5m

pystan-2.15.0.0-cp35-cp35m-manylinux1_i686.whl (61.6 MB view details)

Uploaded CPython 3.5m

pystan-2.15.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 (44.2 MB view details)

Uploaded CPython 3.5m macOS 10.10+ intel macOS 10.10+ x86-64 macOS 10.6+ intel macOS 10.9+ intel macOS 10.9+ x86-64

pystan-2.15.0.0-cp34-cp34m-manylinux1_x86_64.whl (62.4 MB view details)

Uploaded CPython 3.4m

pystan-2.15.0.0-cp34-cp34m-manylinux1_i686.whl (61.6 MB view details)

Uploaded CPython 3.4m

pystan-2.15.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 (44.2 MB view details)

Uploaded CPython 3.4m macOS 10.10+ intel macOS 10.10+ x86-64 macOS 10.6+ intel macOS 10.9+ intel macOS 10.9+ x86-64

pystan-2.15.0.0-cp27-cp27mu-manylinux1_x86_64.whl (62.4 MB view details)

Uploaded CPython 2.7mu

pystan-2.15.0.0-cp27-cp27mu-manylinux1_i686.whl (61.6 MB view details)

Uploaded CPython 2.7mu

pystan-2.15.0.0-cp27-cp27m-manylinux1_x86_64.whl (62.4 MB view details)

Uploaded CPython 2.7m

pystan-2.15.0.0-cp27-cp27m-manylinux1_i686.whl (61.6 MB view details)

Uploaded CPython 2.7m

pystan-2.15.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 (44.2 MB view details)

Uploaded CPython 2.7m macOS 10.10+ intel macOS 10.10+ x86-64 macOS 10.6+ intel macOS 10.9+ intel macOS 10.9+ x86-64

File details

Details for the file pystan-2.15.0.0.tar.gz.

File metadata

  • Download URL: pystan-2.15.0.0.tar.gz
  • Upload date:
  • Size: 25.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pystan-2.15.0.0.tar.gz
Algorithm Hash digest
SHA256 5dc420277eadb72c459bc550feb8d43edb98f328141b4ccaaa4d0a0baaefd7f1
MD5 2538f63c1c66f444ee933555842cdf95
BLAKE2b-256 5dbd9232420cba30e8c9ca9a5c8c1a4503cdb157e39ccf7b3d0b0cb69902cb09

See more details on using hashes here.

File details

Details for the file pystan-2.15.0.0-cp36-cp36m-win_amd64.whl.

File metadata

File hashes

Hashes for pystan-2.15.0.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 a979c0a04e3685ae720b949ffd930e69d6321757be8676bc96d78fc8d8feef20
MD5 33ece654ea3f28a5c3c76f6f262d31c6
BLAKE2b-256 5bf927365812c93d81e54997d7f6340e5bccb92f75a5af71240a8ec584b87189

See more details on using hashes here.

File details

Details for the file pystan-2.15.0.0-cp36-cp36m-win32.whl.

File metadata

File hashes

Hashes for pystan-2.15.0.0-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 f1c4999131d9b0393b11095abff738bc3b66fed6b8a903394b0ddf5543df3372
MD5 deb1c023894a4b6df800637269ea5967
BLAKE2b-256 c29a21d96691b59940d0bdc97c5d61e5e42da52eef2bb555cdd1b145a2cd9575

See more details on using hashes here.

File details

Details for the file pystan-2.15.0.0-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pystan-2.15.0.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 1220505a4791801be2936aaa898739ef8f7f1cf681e589387b68ef19396607e0
MD5 6a1b2de150e31d29802b6f914d72f2a2
BLAKE2b-256 6b43b7474e664f3c391c7be635c68c0b7e730289558a5a93b1338c8187f80239

See more details on using hashes here.

File details

Details for the file pystan-2.15.0.0-cp36-cp36m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for pystan-2.15.0.0-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 dfbbc4f41c1d9bba106e1b78a65f64d34e8c8854ab2d5e77e181040db03d42de
MD5 6ce62c51831d90c3530d766620ed8426
BLAKE2b-256 8a2e324ff4fbfdda03dcda4f461dfd03b6df6d0f01a612323815bbb24608cdb5

See more details on using hashes here.

File details

Details for the file pystan-2.15.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.

File metadata

File hashes

Hashes for pystan-2.15.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
Algorithm Hash digest
SHA256 4e6d3a443521660a07c354a3de83870b1699b2f95b0796705588997deb3e069a
MD5 1743cd13a45a5b9c30ef345e161f82af
BLAKE2b-256 0caf7bdc8fd11c0acf5ed84ad6129fa035d7b6bb158d31eb301ee3d585170ae2

See more details on using hashes here.

File details

Details for the file pystan-2.15.0.0-cp35-cp35m-win_amd64.whl.

File metadata

File hashes

Hashes for pystan-2.15.0.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 0a1b25d972699180a1a54b333862bfb9da4506518177d85f276d0e9751cd4074
MD5 19ed75f77173393bded9553acc6b1b9e
BLAKE2b-256 00c1cd8a9fe6faf518c64daab11b684731e81aa99fe151af4b965e448eb63b09

See more details on using hashes here.

File details

Details for the file pystan-2.15.0.0-cp35-cp35m-win32.whl.

File metadata

File hashes

Hashes for pystan-2.15.0.0-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 3029de1be3880d3b10d7982c63cc4b67708a889e8a3c0203912e68155186606b
MD5 388526cdcaf83aa7e0af5bbd61741648
BLAKE2b-256 c7560ee6e7ce79818552961148d863ba50ffcd228fd5eb08b9983706b8ae6a29

See more details on using hashes here.

File details

Details for the file pystan-2.15.0.0-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pystan-2.15.0.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ea0f6ae41cc148ce17b98cf43e5a375ecf1ddae99d221322ec8bbff8e500e0d4
MD5 daa7aa4cc4c8883119273aaa969cea2d
BLAKE2b-256 05c88a20608e15441d2b634d603d0c3dd59f7102994ea0b43dd94b3946ef5823

See more details on using hashes here.

File details

Details for the file pystan-2.15.0.0-cp35-cp35m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for pystan-2.15.0.0-cp35-cp35m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 6134db9d3bd8fd5150632e0f51e005bd5aacdb9c88842a7c0f0d62c5ea6d8a2d
MD5 efa149c25d9ac10e024dc7fbcd75cf19
BLAKE2b-256 1c119f2d507b185eca0025d8cdadcaca1c2c71964c6168e3318f4cb0f1e7b7b3

See more details on using hashes here.

File details

Details for the file pystan-2.15.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.

File metadata

File hashes

Hashes for pystan-2.15.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
Algorithm Hash digest
SHA256 dfae3aa8da8207ba3fc467da244428eafe658ba40c19eacc7333e6ec4b23cdd7
MD5 2db7f6a9d8c6dc10df5857e669e3900c
BLAKE2b-256 7d5ef5acd7a6acffc75f7c654cb92802988bc5eb49ac1249e52a0d995483060e

See more details on using hashes here.

File details

Details for the file pystan-2.15.0.0-cp34-cp34m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pystan-2.15.0.0-cp34-cp34m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 7134b05adf6cd20bfc1de38ce204fde607b3ecb519bf2260668e5e86d15285d5
MD5 405a70174463abe59b5e4c635a6c619d
BLAKE2b-256 bd87c99677762c01d3efabab752eebc88e91956bb818fb14df7948cc09c6677b

See more details on using hashes here.

File details

Details for the file pystan-2.15.0.0-cp34-cp34m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for pystan-2.15.0.0-cp34-cp34m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 ae45267147ff127e1649beb715a24a0a9655686389e8e77cf70f8c2d9f485bd4
MD5 b6fa7c02fd245d63faa4344796a0fd7f
BLAKE2b-256 168194e623876d1194ad07873238861259174e38a756ba37a4f7bad08ef722bd

See more details on using hashes here.

File details

Details for the file pystan-2.15.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.

File metadata

File hashes

Hashes for pystan-2.15.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
Algorithm Hash digest
SHA256 768f860d3e396ab6ccb907363cb7ac8728c9e89e18451923755702a1f4cf31ee
MD5 c63e8dc60cc6a5a2f1bbe6ec1cd815a7
BLAKE2b-256 660d16a4662e547033a4b75d5dc0771a2472b69a30fc7aae3bf7763585c4d22b

See more details on using hashes here.

File details

Details for the file pystan-2.15.0.0-cp27-cp27mu-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pystan-2.15.0.0-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 a3c1ac6d1611979fca01759c672a95e084f7bc6457ac680db159c6849e3d5f96
MD5 7823bbdd74370b2853d3af319e4e7534
BLAKE2b-256 aec0dd63fd597276649e2d2a43bc8ed2cba3350ac39c7071d58f454148710c61

See more details on using hashes here.

File details

Details for the file pystan-2.15.0.0-cp27-cp27mu-manylinux1_i686.whl.

File metadata

File hashes

Hashes for pystan-2.15.0.0-cp27-cp27mu-manylinux1_i686.whl
Algorithm Hash digest
SHA256 49402f955ef7b545480aa30b162a9b780e36cb610d32bfd6cff9c54eefcdad2f
MD5 c521f96748f822427c55aa390835359c
BLAKE2b-256 5bc091f463fb25914ecb0b8eb0aa129bea88dfd9840717321226bbf7b2f029ce

See more details on using hashes here.

File details

Details for the file pystan-2.15.0.0-cp27-cp27m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pystan-2.15.0.0-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 0074d25f4524f50237d8652aba968279809fbc96725299a7da6ac3393e9dbe65
MD5 1830bd504976bd5e299ea105132743ca
BLAKE2b-256 cea393d14b35eb2f40472451c49cfdc3a729b072468308d8f663b21fcbedd577

See more details on using hashes here.

File details

Details for the file pystan-2.15.0.0-cp27-cp27m-manylinux1_i686.whl.

File metadata

File hashes

Hashes for pystan-2.15.0.0-cp27-cp27m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 365678c0ec92df3eb453bafa049e1ef9a79996d501f8b10a88ae4d824700fc26
MD5 24a6592337082510e2da87b33577290d
BLAKE2b-256 511cc45772395fcad445000f404c7d68bcde7246416bea06f7876b0ddc37b184

See more details on using hashes here.

File details

Details for the file pystan-2.15.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.

File metadata

File hashes

Hashes for pystan-2.15.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
Algorithm Hash digest
SHA256 059a700e25e66a3c5ac3a939d9f01ad4c9e2158f2baac7cfee260e9ef2b6c339
MD5 f31cc3e6ac80a54a8cd09305fdb37d33
BLAKE2b-256 d0577511af2fb2d7bf610910b271ff442353f7422bc98863be3287b1735a4d9f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page