← Back to Blog
October 22, 2026 5 min read

Thompson Sampling, UCB1 or Epsilon Greedy: Choosing a Bandit Algorithm

banditsthompson samplingucb1epsilon greedy

Experiment Flow offers three bandit algorithms: Thompson sampling, UCB1 and epsilon greedy. All three balance two jobs, learning which option is best and sending traffic to it. They differ in how they explore, which makes each a better fit for certain situations.

Thompson sampling, the default

Thompson sampling keeps a Beta distribution for each arm, starting from a uniform prior. On every request it draws one sample per arm and serves the arm with the highest draw. Arms with strong results win draws often. Arms with little data have wide distributions, so they still win a fair share of draws and get tested. Exploration fades naturally as evidence grows.

It is the default in Experiment Flow because it adapts smoothly with no tuning. It suits headlines, prices, images, offers and most everyday decisions. When in doubt, start here.

UCB1, optimism with a schedule

UCB1 tries every arm once, then serves the arm with the highest average reward plus a confidence bonus. The bonus is larger for arms with fewer pulls, so less tested arms get attention until their estimate firms up. The selection is deterministic given the history, which makes behavior easy to reason about and reproduce. Choose UCB1 when you value predictable, explainable allocation.

Epsilon greedy, simple and steady

Epsilon greedy serves the best known arm most of the time and picks a random arm for a fixed fraction of requests. That fraction is easy to explain to a team: "ten percent of traffic keeps exploring." It is a friendly option when you want a constant exploration budget, for example in a catalog where new options appear regularly.

Quick comparison

  • Thompson sampling: adaptive exploration, no tuning, strong default.
  • UCB1: deterministic, confidence driven, easy to audit.
  • Epsilon greedy: fixed exploration share, simplest to explain.

How rewards work

Each arm learns from the rewards you report. With Thompson sampling, a positive reward adds to the arm's success count and a zero reward adds a failure. Rewards between 0 and 1 work nicely, so a purchase can be 1 and a visit without purchase 0. Report the reward after the outcome is known, using the same visitor ID you used when selecting the arm.

Wire it up in two calls

Create the bandit through the API with a name, arms and algorithm. The algorithm field accepts "thompson" (the default), "ucb1" or "epsilon".

POST /api/bandits
{"name": "Pricing Test", "arms": ["$9.99", "$19.99", "$29.99"], "algorithm": "thompson"}

Then use the SDK on your page:

ef.selectArm(banditId, function (arm) { showPrice(arm); });
// later, when the visitor converts
ef.banditReward(banditId, 1);

Bandit or fixed split?

Choose a fixed split when you need a clean estimate of the size of an effect for a report or a major decision. Choose a bandit when the goal is to earn more while you learn, as with promotions, rotating content and short campaigns. For one visitor in particular, such as showing the best offer for a given context, take a look at personalization, which uses contextual bandits.

Try it

Pick an algorithm, add your arms, and watch traffic flow toward your best option. Start free and create your first bandit in a few minutes.

Ready to optimize your site?

Start running experiments in minutes with Experiment Flow. Plans from $29/month.

Get Started