Guide

Thompson Sampling explained

The Beta-Bernoulli model behind automatic A/B testing: how the allocation is drawn, how it updates, and what win probability actually means.

Thompson Sampling is the algorithm behind automatic A/B testing. It is a multi-armed bandit method, and it is worth understanding because the intuition is simple and the consequences for your budget are not.

The problem it solves

You have several landing page variants. Each has an unknown true conversion rate. Every visitor you send is a choice:

  • Send them to the variant you currently believe is best → exploit, but you might be wrong.
  • Send them to a variant you are unsure about → explore, to reduce uncertainty.

A fixed 50/50 split ignores this trade-off entirely. Thompson Sampling resolves it by drawing from what it believes.

The model: Beta-Bernoulli

For a binary outcome (lead / no lead), each variant’s conversion rate is modelled as a Beta distribution:

  • Start with Beta(1, 1) — a flat prior, meaning “I have no idea, anything from 0% to 100% is plausible”.
  • On a lead: increment the first parameter. Beta(2, 1), Beta(3, 1), …
  • On no lead: increment the second. Beta(3, 2), Beta(3, 3), …

So after s leads and f non-leads, a variant holds Beta(s + 1, f + 1). The mean of that distribution is approximately s / (s + f), and its spread shrinks as evidence accumulates. Beta is used because it is the conjugate prior of the Bernoulli distribution: the update is a single increment, not a fitting procedure.

The decision rule

On every visitor:

  1. Draw one random sample from each variant’s Beta distribution.
  2. Serve the variant whose sample was highest.
  3. Record the outcome and update that variant’s distribution.

That is the entire algorithm. No thresholds, no sample size calculation, no stopping rule.

Why it works, intuitively

Early on, every distribution is wide and overlapping, so the draws are effectively random and traffic splits roughly evenly. That is the exploration phase, and it costs little because you had no information anyway.

As one variant accumulates evidence, two things happen at once: its distribution’s mean rises and its spread narrows. A narrow distribution with a high mean wins most draws; a narrow distribution with a low mean almost never wins; a wide distribution still occasionally produces a high sample, so it keeps getting a trickle of traffic.

The result is that traffic concentrates on the leader while the laggards retain a small chance to prove themselves. The exploration never goes to zero.

An illustrative trace

Two variants, no prior information, 100 visitors per round. Numbers are illustrative:

VisitorsVariant A (leads / visitors)Variant B (leads / visitors)Traffic to B
00 / 00 / 0~50%
504 / 509 / 50~65%
15010 / 13032 / 170~85%
40022 / 30078 / 500~93%

Variant A is not abandoned. Its distribution keeps a thin tail, so it keeps receiving a small share — which is what would let it recover if, say, the traffic source changed and its conversion rate improved.

What “win probability” means

The number shown in the product is P(variant i has the highest true conversion rate among the variants).

It is computed by drawing many samples from each distribution and counting how often variant i produces the highest. It is a statement about your belief, not a promise about the future: with two variants and 20 leads each, a 90% win probability means “the evidence points here”, not “this will convert 90% of the time”.

Two consequences worth internalising:

  • Win probability is not a conversion rate. A variant can be 95% likely to be the best of a bad set.
  • It moves as traffic arrives. A 70% reading is not a verdict; it is a snapshot that will drift.

Regret, in one line

The theoretical justification for bandits is regret: the cumulative cost of having served the worse variant. A fixed equal split accumulates regret linearly in the number of visitors — you pay the gap on every single one. A well-designed bandit accumulates regret logarithmically. For a lead generation budget, that difference is the point.

Last updated: 2026-09-21

FAQ

Does Thompson Sampling need a significance threshold?+

No. There is no p-value to cross, because the method does not test a null hypothesis. It maintains a belief about each variant and allocates traffic in proportion to how likely each is to be the best. You read a win probability instead of a significance level.

Is it safe to keep exploring forever?+

It is not exploring at a fixed rate. A variant that is clearly worse gets progressively less traffic, but never exactly zero — that residual exploration is what lets it recover if the audience changes.

Ready to find out what
converts, for real?

Free to start.

Start free →