pymc
Probabilistic Programming in Python: Bayesian Modeling and Probabilistic Machine Learning with PyTensor
What it is and what it does
PyMC is a framework for specifying and fitting Bayesian statistical models using probabilistic programming. It translates intuitive mathematical notation (like x ~ N(0,1)) into executable inference code, handling the computational complexity of sampling from posterior distributions. The package combines advanced sampling algorithms—including the No U-Turn Sampler—with variational inference methods for both exact and approximate posterior estimation, making it suitable for models ranging from simple regression to complex hierarchical structures.
Under the hood, PyMC relies on PyTensor for computation optimization and can compile models to C or JAX for performance. It integrates with numpy, scipy, and pandas for data handling, and uses arviz for posterior analysis and visualization. The package is designed for researchers and practitioners who need flexible Bayesian inference without deep expertise in sampling algorithm implementation.
Use it for:
- Fit Bayesian linear or generalized linear regression models to estimate parameter uncertainty and credible intervals.
- Perform hierarchical modeling for grouped data, such as multi-site experiments or nested study designs.
- Conduct prior sensitivity analysis and posterior predictive checks to validate model assumptions.
- Estimate missing values in datasets using transparent imputation within a probabilistic framework.
- Compare competing Bayesian models using posterior predictive distributions and information criteria.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
PyMC is a Python package for Bayesian statistical modeling and probabilistic programming, providing advanced MCMC and variational inference algorithms for parameter estimation and posterior inference.
Yes. PyMC is production-stable (Development Status 5), actively maintained with a recent release, carries no known vulnerabilities, and uses a permissive Apache 2.0 license. It has low install friction and broad adoption (top 5000 on PyPI). Install it if you need to fit Bayesian models with flexible inference algorithms; avoid it only if you require Python versions below 3.12 or have no need for probabilistic modeling.
Install
pymc on PyPI
pip
pip install pymcuv
uv add pymcpoetry
poetry add pymcInstalling pymc
Before you install
Low install friction with a pure-Python wheel distribution. Active maintenance with a release 2 days old and 9710 repository stars. Requires Python 3.12 or later and depends on 10 runtime packages including numpy, scipy, pytensor, and arviz.
License in practice
Licensed under Apache License 2.0 (permissive), allowing commercial and private use with minimal restrictions beyond attribution and liability disclaimers.
Quickstart
import pymc as pm
import numpy as np
# Define a simple Bayesian model
with pm.Model() as model:
mu = pm.Normal('mu', mu=0, sigma=1)
obs = pm.Normal('obs', mu=mu, sigma=1, observed=np.array([1, 2, 3]))
idata = pm.sample(random_seed=42)
print(pm.stats.summary(idata))
Requires Python 3.12 or later; computationally intensive models may benefit from a system with multiple CPU cores due to threadpoolctl dependency.
Verify before relying
- Whether JAX compilation support is available out-of-the-box or requires additional setup beyond the listed dependencies.
- Performance characteristics and scalability limits for models with thousands of parameters mentioned in the description.
Package facts
| License | Apache License, Version 2.0 (permissive) |
| Python support | supports the current Python release (>=3.12) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 10 — arviz, cachetools, cloudpickle, numpy, pandas, pytensor, rich, scipy, threadpoolctl, typing-extensions |
| Maintenance | actively maintained — 2 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 5,495,668/month — #2,088 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pymc-6.3.0-py3-none-any.whl
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
nutpienutpie provides a fast NUTS sampler for…
permissive · top 15,000 on PyPI
pymc3PyMC3 is a Python package for Bayesian…
permissive · top 15,000 on PyPI
pymc-extrasExtends PyMC with specialized distributions,…
permissive · top 15,000 on PyPI
pystanPyStan provides a Python interface to Stan for…
permissive · top 5,000 on PyPI
pymc-marketingPyMC-Marketing provides Bayesian statistical…
permissive · top 15,000 on PyPI
emceeemcee implements affine-invariant ensemble…
permissive · top 5,000 on PyPI
cmdstanpyCmdStanPy provides a pure-Python interface to…
permissive · top 5,000 on PyPI
numpyroNumPyro is a probabilistic programming library…
permissive · top 15,000 on PyPI
pyAgrum-nightlypyAgrum is a Python library for creating,…
unclear · top 15,000 on PyPI
pyro-apiProvides a generic dispatch API for…
permissive · top 5,000 on PyPI