24 — Make Decisions

Bayesian A/B Testing#

Experimentation✓ Mathematical
◆ The PatternIs version B actually better? Credible intervals and probability of improvement

Bayesian A/B testing gives you what you actually want: "the probability that B is better than A." Unlike frequentist tests, you can check results early, get direct probability statements, and don't need fixed sample sizes.

P(B > A | data) = ∫ P(θB > θA) dθ
P(B > A) = direct probability of improvement. No p-values, no confusion.
Beta(a + successes, b + failures)
For conversion rates, the Beta-Binomial model gives exact posteriors. a=b=1 is a uniform prior.
// Interactive — two posteriors, see probability of B > A
A conversions50
B conversions60
P(B>A)
# Python — Bayesian A/B test
from scipy.stats import beta
import numpy as np

# Observed data
a_conv, a_total = 50, 1000
b_conv, b_total = 60, 1000

# Posterior distributions (uniform prior)
post_a = beta(a_conv + 1, a_total - a_conv + 1)
post_b = beta(b_conv + 1, b_total - b_conv + 1)

# P(B > A) via simulation
samples = 100000
p_b_wins = (post_b.rvs(samples) > post_a.rvs(samples)).mean()
print(f"P(B > A) = {p_b_wins:.3f}")
Pattern bridge: Bayesian updating is the same Bayes' theorem from ML. Prior belief + data = posterior. This connects to market sentiment — prices update beliefs with every new trade.
← Previous
Bootstrap Methods
Open in the full reader, with the topic sidebar →