Skip to main content

CmdStanPy

codecov

CmdStanPy is a lightweight interface to Stan for Python users which provides the necessary objects and functions to do Bayesian inference given a probability model written as a Stan program and data. Under the hood, CmdStanPy uses the CmdStan command line interface to compile and run a Stan program.

Goals

  • Clean interface to Stan services so that CmdStanPy can keep up with Stan releases.

  • Provide access to all CmdStan inference methods.

  • Easy to install,

    • minimal Python library dependencies: numpy, pandas
    • Python code doesn't interface directly with c++, only calls compiled executables
  • Modular - CmdStanPy produces a MCMC sample (or point estimate) from the posterior; other packages do analysis and visualization.

Docs

See https://cmdstanpy.readthedocs.io/en/latest/index.html

Source Repository

CmdStan's source-code repository is hosted here on GitHub.

Licensing

The CmdStanPy, CmdStan, and the core Stan C++ code are licensed under new BSD.

Example

::

import os
from cmdstanpy import cmdstan_path, CmdStanModel

# specify locations of Stan program file and data
bernoulli_stan = os.path.join(cmdstan_path(), 'examples', 'bernoulli', 'bernoulli.stan')
bernoulli_data = os.path.join(cmdstan_path(), 'examples', 'bernoulli', 'bernoulli.data.json')

# instantiate a model; compiles the Stan program by default
bernoulli_model = CmdStanModel(stan_file=bernoulli_stan)

# obtain a posterior sample from the model conditioned on the data
bernoulli_fit = bernoulli_model.sample(chains=4, data=bernoulli_data)

# summarize the results (wraps CmdStan `bin/stansummary`):
bernoulli_fit.summary()

Release files for cmdstanpy 0.9.63

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

Source distribution (sdist)

Source distribution for cmdstanpy 0.9.63
File Size Uploaded
cmdstanpy-0.9.63.tar.gz 51.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cmdstanpy 0.9.63
File Interpreter ABI Platform
cmdstanpy-0.9.63-py3-none-any.whl Python 3 none any Details

Total release size: 93.1 kB

Release files / cmdstanpy-0.9.63.tar.gz

Download URL cmdstanpy-0.9.63.tar.gz
Size 51.8 kB
Tags Source
SHA-256 checksum
How to use checksums
edbfe05a06619d9652d275551504967ce926613de039ed277914d4df465a0261
BLAKE2b-256 checksum
How to use checksums
04d08d960fa3a37c31907a8b7084cc67c8d59b57a43ba4a41938f278e6ee4e2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.0

Release files / cmdstanpy-0.9.63-py3-none-any.whl

Download URL cmdstanpy-0.9.63-py3-none-any.whl
Size 41.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
852a67d5937548efcff5dd57ae9de3647718b14924e03a6a7f20bf5cfc851360
BLAKE2b-256 checksum
How to use checksums
8e056e055c71d2ddcc48bc5496364e193dd023a75a4aebe6c373f28dd2add6d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.0

Release history Release notifications | RSS feed

1.3.0

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.9.77

2 release files

0.9.76

2 release files

0.9.75

2 release files

0.9.68

2 release files

0.9.67

1 release file

This release

0.9.63 This release

2 release files

0.9.6

2 release files

0.9.5

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

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