TapCub is live — analytics, insights and live chat, free on one platform
Glossary

What is a multi-armed bandit? Algorithms, examples and vs A/B testing

A multi-armed bandit shifts traffic toward the better-performing option while a test is still running, trading statistical certainty for fewer lost conversions. How it works, three algorithms, worked numbers and when an A/B test is the better choice.

Su He Reviewed by Lin Zhou Also called MAB Last updated Nov 7, 2026 Glossary

Quick answer

A multi-armed bandit is a testing approach in which traffic is allocated adaptively: options that perform better receive more traffic as results come in, balancing exploration (learning which option is best) against exploitation (using the best option found so far).

Formula: Regret = n × μ* − Σ rewards; UCB1 score = x̄ᵢ + √(2 ln t ÷ nᵢ)

What is a multi-armed bandit?

A multi-armed bandit is a way of testing several options while the test is running and earning: instead of splitting traffic evenly until the end, it gradually sends more visitors to the options that are performing better. It balances exploration (trying options to learn which is best) with exploitation (using the best option found so far).

The name comes from slot machines, nicknamed "one-armed bandits". Picture a row of machines with unknown payout rates. Pull only the one that paid first and you may miss a better one; keep pulling all of them equally and you waste money on the bad ones. Bandit algorithms decide how to split the pulls.

Exploration, exploitation and regret

The cost of testing is called regret: the reward you missed by not always choosing the best option.

Example (sample data). Two landing pages convert at 5% and 6%. A classic A/B test sends 10,000 visitors 50/50:

  • 5,000 × 5% + 5,000 × 6% = 250 + 300 = 550 conversions
  • Sending everyone to the better page would have produced 10,000 × 6% = 600
  • Regret = 600 − 550 = 50 conversions

A bandit reduces that regret by shifting traffic toward the 6% page as evidence builds up. The price is that the weaker page gets fewer visitors, so you learn less precisely how much worse it is.

Common bandit algorithms

AlgorithmHow it choosesStrengthWeakness
Epsilon-greedyShows the current best option most of the time; a fixed share (ε, e.g. 10%) of traffic goes to a random optionSimple to explain and buildKeeps exploring bad options at the same rate indefinitely
Upper Confidence Bound (UCB1)Picks the option with the highest x̄ᵢ + √(2 ln t ÷ nᵢ): its average plus a bonus for being under-testedNo randomness; strong guaranteesAssumes stable conversion rates
Thompson samplingKeeps a probability distribution per option, draws one value from each, shows the highest drawAdapts quickly; works well in practiceHarder to explain to stakeholders

A worked example: Thompson sampling

Sample data: three email headlines after the first 1,000 sends.

HeadlineSendsConversionsRate
A334133.9%
B333175.1%
C333216.3%

Thompson sampling models each rate as a Beta distribution: Beta(1 + conversions, 1 + non-conversions). Drawing from the three distributions many times (we ran 200,000 draws), C has the highest draw 71.3% of the time, B 23.9% and A 4.9%. So the next batch is split roughly 71 / 24 / 5. B still gets meaningful traffic because it could plausibly be the best; A is nearly retired but not ruled out. After each batch the distributions are updated and the split recalculated.

Multi-armed bandit vs A/B testing

A/B testMulti-armed bandit
GoalLearn the true differenceMaximise conversions during the test
Traffic splitFixed until the endShifts toward winners
OutputEffect size, confidence interval, p-valueMostly "which option to keep"
Best forProduct decisions, pricing, long-term metricsShort campaigns, headlines, promotions, many variants
RiskLost conversions while testingBiased estimates; misleading if behaviour changes over time

Rule of thumb: use a bandit to earn, an A/B test to learn. If the variant will live for years, the learning is worth more than a few days of extra conversions.

Contextual bandits

A contextual bandit also uses information about the visitor (device, country, new vs returning) to choose. It can learn that headline B works on mobile and C on desktop. It needs much more traffic and careful feature design, and it behaves like a recommendation system more than a test.

Pitfalls

  • Delayed conversions. If purchases arrive days after the click, the bandit allocates on incomplete data and over-rewards whatever converts fast.
  • Changing behaviour. Weekday vs weekend audiences convert differently. When allocation changes over time, pooled results can mislead, a form of Simpson's paradox.
  • No clean inference. Standard p-values assume fixed allocation. If you need significance, use an A/B test or a method built for adaptive designs such as sequential testing.
  • Too many arms, too little traffic. With ten options and 500 visitors a week, nothing converges.

Multi-armed bandits and TapCub

TapCub is an analytics tool; it does not allocate traffic, run A/B tests or bandits. If your testing or email tool runs the bandit, send the variant as an event property, for example tapcub.track('headline_view', { variant: 'C' }), and break down the conversion event by that property in event analysis. That gives you an independent check on what the bandit reports, including downstream outcomes it cannot see, such as retention.

Sources

Was this explanation clear?

We use your answers to fix and expand this page.

Su He

Data Analyst

Explores traffic sources, conversion funnels, and retention, using clear metric definitions and concrete examples to explain what the numbers mean.

FAQ

Questions people ask

Short answers to the follow-up questions that come up most.

Still have a question?

Chat with the team behind TapCub — we usually reply within a few hours on business days.

Why is it called a multi-armed bandit?

Slot machines were nicknamed one-armed bandits. The problem imagines a gambler facing several machines with unknown payouts who must decide which arms to pull to win the most overall.

Is a multi-armed bandit better than an A/B test?

It is better at limiting lost conversions during the test, and worse at telling you how big the difference is and whether it is real. Use a bandit to earn, an A/B test to learn.

What is Thompson sampling?

A bandit algorithm that keeps a probability distribution for each option's conversion rate, draws one random value from each, and shows the option with the highest draw. Options likely to be best get shown more often.

When should you not use a bandit?

When the success metric is delayed (retention, revenue over months), when user behaviour changes over time, or when you need a clean estimate of the effect for a product decision.

See this number on your own site

Add one script tag for web and apps, and the first reports fill in within minutes.

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics