Back to BlogGuide

Why Bandit Runs Thompson Sampling and Not Epsilon-Greedy or UCB1

6 min read

Three Algorithms, One Goal

Every multi-armed bandit algorithm tries to solve the same problem: maximize total reward by balancing exploration and exploitation. But they approach this trade-off with fundamentally different strategies.

Epsilon-Greedy uses randomness. UCB1 uses optimism. Thompson Sampling uses probability. Each philosophy leads to different behavior in practice.

Note

Bandit runs Thompson Sampling only. Epsilon-Greedy and UCB1 are not options in the product, and this post is the argument for why. If you just want the answer: Thompson Sampling wins on regret in essentially every setting we care about, and the two things the others were good for turned out to be better solved another way. The comparison below is here so you can check our work rather than take our word for it.

Epsilon-Greedy

  • Strategy: randomness
  • Explores a random arm with probability epsilon (default 0.1)
  • Requires tuning the epsilon parameter
  • Linear regret bound

UCB1

  • Strategy: optimism
  • Picks the arm with the highest upper confidence bound
  • No tuning parameters, fully deterministic
  • Logarithmic regret bound

Thompson Sampling

  • Strategy: probability
  • Samples from each arm's Beta distribution and picks the highest
  • No tuning parameters, adapts to non-stationary data
  • Logarithmic regret bound, lowest empirical regret
The three core strategies for balancing exploration and exploitation

Epsilon-Greedy: The Simple Baseline

Epsilon-Greedy is the most intuitive bandit algorithm. With probability 1 - epsilon, it picks the arm with the highest observed reward (exploit). With probability epsilon, it picks a random arm (explore).

How it works:

  1. Generate a random number between 0 and 1
  2. If the number is less than epsilon (default 0.1), pick a random arm
  3. Otherwise, pick the arm with the highest average reward

Strengths:

  • Dead simple to implement and explain
  • Predictable exploration rate
  • Works with any reward distribution

Weaknesses:

  • Explores uniformly, wasting pulls on clearly bad arms
  • The epsilon parameter needs tuning (too high = too much exploration, too low = gets stuck)
  • Never stops exploring, even when the best arm is obvious

Tip

Epsilon-Greedy's one real advantage is that it is easy to explain: "we show the best variant 90% of the time and try random variants 10% of the time." That is a communication win, not a performance one, and it comes at a steep price. A fixed exploration rate means a fixed share of your traffic is spent on known-bad variants forever, which is exactly why its regret grows linearly rather than logarithmically.

UCB1: Optimism Under Uncertainty

UCB1 (Upper Confidence Bound) takes a different approach. For each arm, it computes an upper confidence bound on the true reward and picks the arm with the highest bound. Arms with less data get wider bounds, so they get explored. Arms with lots of data have tight bounds that reflect their true performance.

The UCB1 formula:

For each arm, the score is: average_reward + sqrt(2 * ln(total_pulls) / arm_pulls)

The first term is exploitation (observed performance). The second term is an exploration bonus that shrinks as you gather more data for that arm.

Strengths:

  • Zero tuning parameters
  • Deterministic: same data always produces the same choice
  • Strong theoretical regret guarantees (logarithmic regret)

Weaknesses:

  • Deterministic behavior can be a liability in non-stationary environments
  • Explores more aggressively than necessary in practice
  • Confidence bounds assume sub-Gaussian rewards
  • Determinism also means every visitor in a burst gets the same arm until the counts move, which concentrates risk in exactly the moments traffic spikes
Exploration bonus: sqrt(2 * ln(total_pulls) / arm_pulls)
Observed average reward (exploitation term)
score contributionarm_pulls
UCB1 balances observed reward with an exploration bonus that shrinks over time

Thompson Sampling: Bayesian Probability Matching

Thompson Sampling maintains a probability distribution over each arm's true reward rate. At each step, it samples from each distribution and picks the arm with the highest sample. Arms with more uncertainty produce more variable samples, so they get explored naturally.

How it works (binary outcomes):

  1. For each arm, maintain a Beta distribution: Beta(successes + 1, failures + 1)
  2. Sample a value from each arm's distribution
  3. Pick the arm with the highest sampled value
  4. Update the selected arm's distribution with the outcome

Strengths:

  • No tuning parameters
  • Naturally concentrates exploration on uncertain arms
  • Lowest empirical regret across most scenarios
  • Adapts well to non-stationary environments (due to stochastic selection)

Weaknesses:

  • Requires choosing a prior distribution (Beta for binary, Normal for continuous)
  • Slightly more complex to implement than Epsilon-Greedy
  • Stochastic behavior makes exact reproducibility harder
Early: Beta(2, 2) after a few trials
Later: Beta(80, 40) after many trials
Thompson Sampling narrows uncertainty as data accumulates, shifting from exploration to exploitation

Head-to-Head Comparison

PropertyEpsilon-GreedyUCB1Thompson Sampling
Tuning requiredYes (epsilon)NoNo
Exploration strategyRandomOptimisticProbabilistic
DeterministicNoYesNo
Regret boundLinearLogarithmicLogarithmic
Empirical regretHighestMediumLowest
Non-stationary environmentsPoorPoorGood
Implementation complexityTrivialSimpleModerate
Cold start behaviorRandom explorationAggressive explorationBalanced exploration

Try It Yourself

The simulator below is a teaching sandbox, not a preview of the product: it runs all three algorithms side by side against the same set of arms so you can watch the difference yourself. Only Thompson Sampling is available on Bandit.

Multi-Armed Bandit Simulator

A teaching sandbox. Bandit runs Thompson Sampling; the others are here for contrast.

Total: 0Rewards: 0

Things to experiment with:

  • Close conversion rates (e.g., 48% vs 52%): Thompson Sampling's advantage is most visible here
  • One dominant arm (e.g., 80% vs 20% vs 15%). All algorithms converge quickly, but Epsilon-Greedy wastes the most traffic
  • Many arms (5+), where UCB1's aggressive exploration becomes costly and Thompson Sampling scales better
Epsilon-Greedy (linear regret)
UCB1 (logarithmic regret)
Thompson Sampling (logarithmic, lowest empirical regret)
cumulative regretrounds (0 to 10,000)
Cumulative regret comparison across 10,000 rounds with 3 arms

What We Concluded

Read that table as a product decision rather than a menu, and the answer is not close.

Epsilon-Greedy's selling point is simplicity, and simplicity is worth nothing once the algorithm is somebody else's problem. You are not implementing it; we are. What you inherit is a tuning parameter you have to defend and a fixed tax on your traffic that never goes away.

UCB1's selling point is determinism, and determinism turns out to be the wrong thing to want here. Reproducibility matters when you are debugging an algorithm. It actively hurts when your winner is drifting, because a deterministic rule commits hard to a stale estimate and needs a large run of contrary evidence to be talked out of it.

Thompson Sampling gives up nothing to either. No tuning, logarithmic regret, and the lowest empirical regret in the benchmarks. Its stochasticity, the thing that makes it non-reproducible, is precisely what keeps it honest when the world moves.

What You Configure Instead

Dropping the algorithm picker did not leave you with fewer decisions, just a better one. Rather than choosing between exploration strategies, you choose the algorithm's memory: how much of the past its posterior still believes.

Standard

  • Every result counts forever
  • The textbook stationary bandit
  • Right for a test you intend to conclude

Discounted

  • A result's weight halves every half-life
  • Old evidence fades, never vanishes
  • Right for always-on tests and gradual drift

Sliding window

  • Only the last N days count at all
  • Hard cut-off, no tail
  • Right when change arrives all at once
What replaced the algorithm picker: three memory modes, all running Thompson Sampling underneath

This is the setting that actually changes outcomes on a live experiment. An always-on test on standard memory eventually stops learning: after enough traffic, no plausible run of new results can move a posterior built from millions of old ones. That is a real failure mode, and none of the three algorithms above fixes it. A half-life does.

The Practical Answer

For teams optimizing web experiences, Thompson Sampling is the best default, which is why it is the only default. It requires no tuning, produces the lowest regret, and handles the messy realities of production environments better than the alternatives.

The question worth your attention is not which algorithm to run. It is whether your winner is going to stay your winner, and how quickly you want the algorithm to notice if it doesn't.

Epsilon-Greedy (not shipped)

  • Wanted for: simplicity of implementation
  • But: you are not the one implementing it
  • Cost: a tuning knob and linear regret

UCB1 (not shipped)

  • Wanted for: deterministic, reproducible choices
  • But: determinism is a liability when the winner drifts
  • Cost: over-exploration, slow to change its mind

Thompson Sampling (shipped)

  • No tuning parameters
  • Lowest empirical regret
  • Stochastic selection survives a moving target
  • Pair with discounted or sliding-window memory
Why one of the three shipped and the other two did not

Ready to try algorithmic testing?

Stop wasting traffic on losing variants. Bandit's multi-armed bandit algorithms automatically shift traffic to your best-performing treatments in real time.

Start free
All articles
Why Bandit Runs Thompson Sampling and Not Epsilon-Greedy or UCB1 — Bandit