PyData Global 2025

Bayesian Decision Analysis with PyMC: Beyond A/B Testing
2025-12-09 , Analytics, Visualization & Decision Science

This hands-on tutorial introduces practical Bayesian inference using PyMC, focusing on A/B testing, decision-making under uncertainty, and hierarchical modeling. With real-world examples, you'll learn how to build and interpret Bayesian models, evaluate competing hypotheses, and implement adaptive strategies like Thompson sampling. Whether you're working in marketing, healthcare, public policy, UX design, or data science more broadly, these techniques offer powerful tools for experimentation, decision-making, and evidence-based analysis.


Bayesian methods offer a natural and interpretable framework for updating beliefs with data, and PyMC makes it easy to apply these techniques in practice. In this tutorial, we’ll walk through a series of examples that demonstrate the core concepts:

  1. Bayesian A/B Testing with the Beta-Binomial Model
  • Represent prior beliefs with the beta distribution
  • Use binomial likelihoods to model observed outcomes
  • Understand posterior distributions and credible intervals
  1. Bayesian Bandits and Thompson Sampling
  • Go beyond hypothesis testing: estimate the probability of one version outperforming another
  • Use Thompson sampling to guide decision-making
  • Simulate and visualize an adaptive email campaign
  1. Hierarchical Models for Partial Pooling and Prediction
  • Learn how to share information across variants
  • Use posterior predictive distributions to quantify uncertainty
  • Understand second-order probabilities

Hands-On Learning

Participants will follow along in Jupyter notebooks (hosted on Colab — no installation required). Exercises are embedded throughout, with guided solutions. Code is based on PyMC, ArviZ, and standard scientific Python libraries.

Prerequisites

  • Intermediate Python: basic familiarity with NumPy, plotting, and Jupyter notebooks
  • No prior experience with Bayesian statistics or PyMC is assumed
  • All materials run on Colab (no setup required)

Prior Knowledge Expected:

Yes

Allen Downey is a principal data scientist at PyMC Labs and professor emeritus at Olin College. He is the author of several books including Think Python, Think Bayes, and Probably Overthinking It -- and a blog about programming and data science. He received a Ph.D. in computer science from the University of California, Berkeley, and Bachelor's and Masters degrees from MIT.