Scientific Computing

pymc

Helps you make smart guesses about uncertain things, and honestly tells you how confident to be.

Install it: pip install pymc

What does it do?

PyMC lets you build statistical models that don’t just spit out a single answer but express genuine uncertainty, like predicting there’s a 70 percent chance sales fall between two numbers next quarter rather than a falsely precise single figure. It’s built around Bayesian statistics, a school of thought in probability that updates its beliefs as new evidence comes in, much like revising your guess about rain after checking the sky a few more times throughout the day. Researchers use it to model everything from disease spread to customer behavior, feeding in what they already know and letting the software work out the most plausible explanations. It automates the genuinely hard math behind these calculations, math that would be impractical to do by hand.

See it in action

This feeds in some observed numbers and has the program work out its best guess, along with how confident it is, about the hidden average and spread behind them.

import pymc as pm

with pm.Model() as model:
    mu = pm.Normal("mu", mu=0, sigma=1)
    sigma = pm.HalfNormal("sigma", sigma=1)
    obs = pm.Normal("obs", mu=mu, sigma=sigma, observed=[1.2, 0.9, 1.1, 1.3])
    trace = pm.sample(1000)

print(pm.summary(trace))

Why would a non-developer care?

Real-world decisions, should we stock more inventory, is this new drug actually working, are rarely certain, and tools that honestly represent that uncertainty tend to lead to better decisions than ones that pretend to know more than they do. It matters to anyone who has been burned by a confident prediction that turned out wrong because it ignored its own uncertainty.

Real-world examples

PyMC has been used in academic research across epidemiology, ecology, and economics to build models that explicitly quantify uncertainty rather than hiding it. Companies doing sophisticated forecasting and A/B testing analysis sometimes use Bayesian approaches like this instead of traditional statistics because they can incorporate prior knowledge more naturally. It’s part of a broader Bayesian statistics movement in data science that’s grown substantially over the past decade as computing power made these previously impractical calculations feasible.

Who uses it

Statisticians, data scientists, and researchers who want to model uncertainty explicitly rather than relying on traditional point-estimate statistics.

How it compares to alternatives

PyMC is one of the most popular Python tools for Bayesian statistical modeling, competing mainly with Stan, which uses its own separate modeling language rather than pure Python, and with newer entrants like NumPyro, which trades some of PyMC’s flexibility for raw speed.

New to Python and want to actually try libraries like this yourself?

Find a beginner-friendly course

Related libraries