Multi-armed bandit is an adaptive experimentation method that splits traffic across several variants and, as data comes in, assigns more visits to the ones that seem to perform best, without waiting for the end of a classic fixed-horizon test. The name comes from the analogy of a slot machine with several arms, each paying out with an unknown probability: the challenge is to find which arm pays the most while losing as little as possible along the way.

How it works

The problem is framed as a trade-off between exploring and exploiting. Exploring means trying less-known variants to learn their real performance. Exploiting means directing more traffic to the variant that, based on the data accumulated so far, has the best conversion rate. A traditional A/B test separates these two phases: it splits traffic evenly until it reaches a sample size and only then decides. The bandit blends them, so every visit serves both to learn and to produce a result.

There are several strategies for deciding the split. The simplest is epsilon-greedy, where most traffic goes to the current leader while a small share is spread at random among the others to keep learning. Other common families include upper confidence bound methods, such as UCB, which favor options with more uncertainty, and Thompson sampling, which assigns each visit according to the probability that each variant is the best, based on a Bayesian model of its results. The right choice depends on how volatile the business is and on the cost of getting it wrong.

It is worth distinguishing its use from an A/B test. A bandit is designed to optimize an outcome while the campaign is running, for example choosing the best headline for a landing page during a seasonal promotion. An A/B test aims to measure the effect of a change rigorously, including its statistical significance. So if your goal is to understand why something works or to document a learning, the classic test remains the more suitable tool.

Practical example

Imagine an online store choosing between three home-page banners: A, B and C. As a hypothesis, suppose their true conversion rates are 10%, 15% and 6%, although the store does not know them at the start. During an initial phase of 300 visits, traffic is split equally, 100 per variant. Imagine the store records 10 conversions with A, 15 with B and 6 with C, that is, 31 in total.

Using a simple rule that sends 80% of the next 900 visits to the current leader, B, and 10% to each of the other two, the split becomes 720 visits for B, 90 for A and 90 for C. With the hypothetical rates above, we would expect about 108 conversions from B, 9 from A and 5.4 from C, roughly 122 in total. Across the 1,200 visits, the cumulative result would be about 153 conversions, close to 12.8%.

If the store had kept an even split for all 1,200 visits, with 400 per variant, the estimate would be 40 + 60 + 24 = 124 conversions, or 10.3%. The gap illustrates the core idea: fewer conversions are lost by showing weaker variants for long. This example is only illustrative. In practice the rates are unknown, and the outcome depends on the daily variability of traffic.

How to apply it step by step

  1. Define a clear reward metric that you can measure quickly, such as CTA clicks, add-to-cart actions or completed sign-ups, and verify that it is tracked correctly in your analytics.

  2. Set the candidate variants and check that they do not overlap with each other or with other experiments affecting the same audience.

  3. Choose the allocation strategy that fits your context: epsilon-greedy for simplicity, or Thompson sampling if you want a finer allocation with explicit uncertainty.

  4. Set an initial exploration phase with a minimum number of visits per variant, so that no option is discarded because of a streak of bad luck.

  5. Monitor the split daily. Confirm that traffic is actually being redistributed, that there are no technical failures, and that the metric is not hiding side effects elsewhere in the funnel.

  6. Decide when to stop the system, for example when one variant leads steadily over a defined period, and document the result.

  7. If you need to explain the effect to stakeholders or replicate the learning, validate the winner with a confirmation A/B test.

Common mistakes

The first is treating a bandit as a classic statistical test and reading its estimates as if they were reliable confidence intervals. Because traffic is redistributed, the samples for each variant become unbalanced, and biases can appear. Another frequent error is stopping too early, when one variant has just overtaken another by chance, or leaving the system running indefinitely without ever reviewing it.

It is also common to ignore non-stationarity. If user behavior changes with seasons, campaigns or prices, the variant that won two weeks ago may not win now. Without forgetting mechanisms or data windows, the algorithm can keep exploiting an outdated option. Finally, teams often choose proxy metrics that do not reflect real business value, such as optimizing clicks that never turn into revenue.

Best practices

Use a bandit when the cost of showing a weaker variant is meaningful and the goal is to optimize rather than to learn. For strategic decisions or changes with product implications, combine the approach with A/B tests that allow effects to be inferred rigorously. Define the stopping criterion and the minimum exploration volume in advance, and avoid changing the rules midway to favor a preferred variant.

Watch data quality closely. Segment results by device, traffic source and user type to detect effects that the average hides, and check that events fire consistently across all variants. If your system supports context, consider contextual bandits, which adapt the split to visitor features, although they add complexity to implementation and analysis. Finally, keep a log of hypotheses and results so that learning accumulates over time.

Frequently asked questions

Does a multi-armed bandit replace A/B testing?

Not necessarily. It replaces A/B testing when the main goal is to maximize results during a campaign, such as choosing a headline or a short-lived offer. To measure the effect of a change with statistical rigor, document it, or make structural decisions, A/B testing remains the reference.

How much traffic do I need to use one?

There is no universal figure. It depends on the conversion rate, the number of variants and the difference you want to detect. With low traffic, estimates are very volatile and the algorithm may make premature decisions, so it is wise to start with few variants and a sufficiently long exploration phase.

Is it compatible with personalization?

Yes. A contextual bandit can choose which content to show based on a visitor profile or behavior, which moves it closer to automated personalization. Even so, it helps to separate what is learned in general from what responds to specific segments, so that effects are not confused and the results remain easy to interpret.