Skip to main content

CmdStanPy

CmdStanPy is a lightweight interface to Stan for Python users which provides the necessary objects and functions to compile a Stan program and run Stan's samplers.

Goals

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

  • Provides complete control - all sampler arguments have corresponding named argument for CmdStanPy sampler function.

  • 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 sample from the posterior, downstream modules do the analysis.

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 Model, StanFit, cmdstan_path

# specify Stan file, create, compile Model object
bernoulli_path = os.path.join(cmdstan_path(), 'examples', 'bernoulli', 'bernoulli.stan')
bernoulli_model = Model(stan_file=bernoulli_path)
bernoulli_model.compile()


# specify data, fit the model
bernoulli_data = { "N" : 10, "y" : [0,1,0,0,0,0,0,0,0,1] }
bernoulli_fit = bernoulli_model.sample(chains=5, cores=3, data=bernoulli_data)

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

Download files

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

Source Distribution

cmdstanpy-0.4.0.tar.gz (24.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cmdstanpy-0.4.0-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

Details for the file cmdstanpy-0.4.0.tar.gz.

File metadata

  • Download URL: cmdstanpy-0.4.0.tar.gz
  • Upload date:
  • Size: 24.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.0

File hashes

Hashes for cmdstanpy-0.4.0.tar.gz
Algorithm Hash digest
SHA256 5604d20136785b05883eda20a2e8c1a1f47600b148abf68deb12dda6ccd8951f
MD5 513f33f28b4974e706bcf349b3e4ae65
BLAKE2b-256 7d345b35f74836b5cb355d9b5046091e910389d834fef4e8577161ae7d5e048f

See more details on using hashes here.

File details

Details for the file cmdstanpy-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: cmdstanpy-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 22.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.0

File hashes

Hashes for cmdstanpy-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ac2ec8f6ce331ca5b2db5a8ac5f0f34a83571dbb9a2a7d9b9cf7b04ad696cd5
MD5 339330300eb0b4ed8d19af4f60370e09
BLAKE2b-256 e3a76d045520e6ad11cf630b483f02a0645e743fcc7f75c28fd344c769100203

See more details on using hashes here.

Release history Release notifications | RSS feed

1.3.0

2 files

1.2.5

2 files

1.2.4

2 files

1.2.3

2 files

1.2.2

2 files

1.2.1

2 files

1.2.0

2 files

1.1.0

2 files

1.0.8

2 files

1.0.7

2 files

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.9.77

2 files

0.9.76

2 files

0.9.75

2 files

0.9.68

2 files

0.9.67

1 file

0.9.66

2 files

0.9.65

2 files

0.9.64

2 files

0.9.63

2 files

0.9.62

2 files

0.9.61

2 files

0.9.6

2 files

0.9.5

2 files

0.9.2

2 files

0.9.1

2 files

0.9.0

2 files

0.8.0

2 files

0.7.0

2 files

0.6.0

2 files

0.5.0

2 files

0.4.3

2 files

0.4.2

2 files

0.4.1

2 files

This release

0.4.0 This release

2 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