--- id: pystan version: "3.10.1" license: ISC license_treatment: permissive maintenance: active --- # pystan — Python interface to Stan, a package for Bayesian inference License: permissive · Maintenance: active · Downloads: 1.4M/mo ## What it is and what it does PyStan is a Python interface to Stan, a platform for Bayesian statistical modeling and computation. It lets you define probabilistic models in Stan's modeling language, then compile and sample from them in Python. The package handles model compilation caching and sample caching automatically, reducing redundant computation. Typical workflows involve writing a Stan model specification that defines data, parameters, and model structure, passing it to PyStan with your data, and drawing posterior samples via Markov chain Monte Carlo. Results can be extracted as arrays or converted to pandas DataFrames for analysis. It's used in social sciences, biology, physics, engineering, and business for statistical inference where you need to quantify uncertainty in model parameters. Use it for: - Fit hierarchical Bayesian models to experimental or observational data with uncertainty quantification - Conduct prior sensitivity analysis and posterior predictive checks for model validation - Estimate treatment effects, causal parameters, or latent variables in complex statistical models - Build time-series or spatial models with structured priors and dependencies - Perform model comparison and selection using posterior samples ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. PyStan provides a Python interface to Stan for Bayesian statistical inference, with automatic caching of compiled models and posterior samples. Yes, if you need Bayesian inference. PyStan is actively maintained, has no known vulnerabilities, and is widely trusted in research and industry. The main requirement is a C++ compiler on your system. Worth installing for any project involving probabilistic modeling, uncertainty quantification, or hierarchical statistical inference. ## Install pip install pystan uv add pystan poetry add pystan ## Installing pystan Before you install: Low friction installation as a pure Python wheel. Actively maintained with recent commits and supports current Python versions (3.12+). Requires a C++ compiler (gcc ≥9.0 or clang ≥10.0) available on your system for model compilation. License in practice: Licensed under ISC, a permissive open-source license. You can use, modify, and distribute PyStan with minimal restrictions, suitable for both academic and commercial projects. Quickstart: pip install pystan import pystan schools_code = """data { int J; }""" schools_data = {"J": 8} posterior = pystan.build(schools_code, data=schools_data) fit = posterior.sample(num_chains=4, num_samples=1000) Requires a C++ compiler (gcc ≥9.0 or clang ≥10.0) installed; runs on Linux and macOS only. Verify before relying: - Whether Windows support is available or planned - Performance characteristics for large models or datasets - Specific use of GPU acceleration or distributed computing ## Package facts - License: ISC (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 1.4M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags bayesian inference python, stan statistical modeling, probabilistic programming, mcmc sampling, hierarchical bayesian models, posterior sampling, statistical computation, bayesian-inference, statistical-modeling, probabilistic-programming [View on SkillFed](https://skillfed.io/packages/pystan) · [View on PyPI](https://pypi.org/project/pystan/)