--- id: emcee version: "3.1.6" license: MIT license_treatment: permissive maintenance: active --- # emcee — The Python ensemble sampling toolkit for MCMC License: permissive · Maintenance: active · Downloads: 846.6K/mo ## What it is and what it does emcee is a production-grade Python implementation of the affine-invariant ensemble sampler for MCMC, a statistical technique for sampling from complex probability distributions. It is commonly used in Bayesian inference, parameter estimation, and model fitting where you need to explore a posterior distribution and extract credible intervals or point estimates. The package wraps the algorithm proposed by Goodman & Weare (2010) and has been used in published astrophysics research. The core dependency is numpy, and the package is designed to run on standard Python without compiled extensions. It provides an ensemble-based approach where multiple parallel walkers explore the parameter space, making it well-suited for problems where traditional single-chain samplers would be slow or inefficient. The API is straightforward: define a log-probability function, initialize an EnsembleSampler, and call run_mcmc to generate samples. Use it for: - Fitting model parameters to observational data in astronomy or physics by sampling the posterior distribution. - Uncertainty quantification in scientific computing where you need credible intervals on fitted parameters. - Bayesian model comparison by computing marginal likelihoods or evidence from MCMC chains. - Calibrating complex simulators or forward models by inferring input parameters that match observed outputs. - Exploratory data analysis in high-dimensional spaces where you need to understand the structure of a probability distribution. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. emcee implements affine-invariant ensemble sampling for Markov chain Monte Carlo (MCMC), enabling Bayesian inference and parameter estimation through parallel sampling of posterior distributions. Yes. emcee is a mature, well-maintained library with low install friction, no known vulnerabilities, and a permissive license. It is the standard choice for ensemble MCMC in Python and has proven utility in published research. Install it if you need to perform Bayesian inference or sample from complex posterior distributions. ## Install pip install emcee uv add emcee poetry add emcee ## Installing emcee Before you install: Low install friction with a single runtime dependency (numpy) and a pure-Python wheel distribution. The package is actively maintained with a recent release and 1597 repository stars, indicating stable community adoption. License in practice: MIT license permits unrestricted commercial and private use, modification, and distribution with minimal restrictions—suitable for most research and production contexts. Quickstart: import numpy as np import emcee # Define log-probability function def log_prob(x): return -0.5 * np.sum(x**2) # Initialize sampler with walkers and dimensions sampler = emcee.EnsembleSampler(n_walkers, n_dims, log_prob) # Run MCMC sampler.run_mcmc(initial_state, n_steps) Verify before relying: - Whether the package supports GPU acceleration or distributed computing beyond standard multiprocessing. - Performance characteristics and scalability limits for high-dimensional parameter spaces. - Compatibility with modern Python versions (requires_python is unspecified in metadata). - Recommended walker count and step count for typical inference problems. ## Package facts - License: MIT (permissive) - Python support: unspecified - Install friction: low - Maintenance: active - Downloads: 846.6K/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags MCMC sampling Python, Bayesian inference ensemble, affine-invariant sampler, posterior estimation, Goodman Weare algorithm, parallel MCMC, parameter fitting Bayesian, bayesian-inference, statistical-sampling, mcmc [View on SkillFed](https://skillfed.io/packages/emcee) · [View on PyPI](https://pypi.org/project/emcee/)