A course in applied Bayesian statistics, built from real data
Learn Bayesian data analysis the way it is actually done: one real problem at a time.
88 worked examples and 15 challenges, each a complete analysis in PyMC, almost all of public datasets. Every page shows the model, the code, the checks that passed and the ones that did not, and what the posterior means for the question that was asked.
Why model this way
Uncertainty is the result
A Bayesian analysis returns a distribution over everything unknown, $p(\theta \mid y) \propto p(y \mid \theta)\,p(\theta)$. Any quantity you compute from the parameters — a forecast, a ranking, a probability that a threshold is crossed — comes with its uncertainty attached, without a separate derivation.
A model is a story about the data
Instead of choosing a test from a menu, you write down how the data could have been generated: censoring, missingness, measurement error, groups, space, time, physics. The same language covers a regression and a gravitational-wave ringdown, so you learn one way of thinking, not a list of procedures.
Checking is part of the method
Priors are simulated before they are trusted, samplers are diagnosed, and fitted models are asked to reproduce the data. When a model fails, these pages say so and show the repair. Seeing the failures is how you learn to spot them in your own work.
The workflow every page follows
The examples are not a tour of an API. Each one is a complete iteration of the Bayesian workflow of Gelman et al. (2020): a question, a generative model, checks before and after fitting, and a conclusion stated on the scale the question was asked in.
- Question. What decision or claim will the model inform? See E01.
- Generative model. A story of how the data came to be, written as distributions. See E01.
- Prior predictive. Simulate before fitting: do the priors claim anything absurd? See D03.
- Inference. Sample the posterior, or approximate it with care. See E12.
- Diagnostics. Did the computation work? Divergences, R-hat, effective sample size. See E02.
- Posterior predictive. Can the fitted model reproduce the features of the data you care about? See E03.
- Decision. Carry the whole posterior through to the quantity someone acts on. See E33.
Three ways in
New to Bayesian modelling
Read the foundations in order. They assume some Python and some regression, nothing more.
A practitioner with a problem
Start from your data, not from a method. The guide maps outcome types, dependence structures and questions to the example that treats them.
Ready to test yourself
Eleven open-ended problems on real data. The brief says what to deliver, never how; the first model you try will break, and finding out why is the exercise.
Recently added
Chaos and how to fit, forecast and control it; regime detection with hidden Markov models; jump-diffusion SDEs for market crashes; reaction-diffusion in cell biology; optimal placement of heaters and sensors for the heat equation; and a flexible response curve for media models, written in JAX.
A few of the case studies
pymc_extras GenExtreme checked against scipy), a geophysical shape prior, a reparameterisation that removes support-wall divergences, non-stationary GEV on smoothed global temperature, …E40Who will win? Dynamic Bayesian poll aggregation and election forecasting2016 US presidential polls (HuffPost Pollster via the Economist's us-potus-model), 1976-2016 state results, fundamentals, ACS state demographicsLinzer reverse random walks from a fundamentals prior, correlated state innovations, house/mode/population effects, poll-level + shared polling error with a rotation for the unidentified truth/bias split, electoral-college simulation and tipping points, …E16Showing uncertainty: one posterior, twenty displaysMotorcycle crash test; Minnesota radon with county boundaries; Premier League 2024/25epistemic vs predictive bands, fan charts, why a band is not a set of curves, spaghetti, animated hypothetical outcome plots, quantile dotplots, exceedance curves, caterpillars and ridgelines, …