Browsed by
Tag: decision analysis

Bayesian Decision Analysis

Bayesian Decision Analysis

At PyData Global 2025 I presented a workshop on Bayesian Decision Analysis with PyMC. The video is available now.

This workshop is based on the first session of the Applied Bayesian Modeling Workshop I teach along with my colleagues at PyMC Labs. If you would like to learn more, it is not too late to sign up for the next offering, starting Monday January 12.

Resources:

Here’s the abstract and description of the workshop.

Bayesian Decision Analysis with PyMC: Beyond A/B Testing

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.

Description

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)

Flipping USB Connectors

Flipping USB Connectors

I am not the first person to observe that it sometimes takes several tries to plug in a USB connector (specifically the rectangular Type A connector, which is not reversible). There are memes about it, there are cartoons about it, and on sites like Quora, people have asked about it more than a few times.

But I might be the first to use Bayesian decision analysis to figure out the optimal strategy for plugging in a USB connector. Specifically, I have worked out how long you should try on the first side before flipping, how long you should try on the second side before flipping again, how long you should try on the third side, and so on.

For a high-level view of the analysis, see this article in Towards Data Science.

For the details, you can  read the Jupyter notebook on the Think Bayes site or run it on Colab.