Multi-Armed Bandit: The Explore vs. Exploit Trade-off

A multi-armed bandit algorithm balances exploring new options with exploiting the current winner, like a gambler trying slot machines to find the best payout.
THE MENTAL MODEL: Imagine you're at a row of slot machines (one-armed bandits). Each has a different, unknown payout probability. You have a limited number of plays and want to maximize your total winnings. Do you keep pulling the arm of the machine that has paid out the most so far (exploitation), or do you try a different machine that might have an even better payout (exploration)? This is the core tension a multi-armed bandit (MAB) algorithm seeks to resolve: balancing using the best-known option against searching for a better one.
HOW IT WORKS: MAB algorithms are strategies for managing this trade-off. Two common approaches are Epsilon-Greedy and Upper Confidence Bound (UCB). In Epsilon-Greedy, you exploit the best-known option most of the time (a probability of 1-epsilon) but reserve a small fraction of your trials (a probability of epsilon) to explore a random option. In UCB, you choose the arm that has the highest potential, calculated as a sum of its observed average reward and an 'uncertainty bonus' that is larger for arms that have been tried less often. This encourages exploring less-tested options.
WHEN TO USE IT: Use a bandit when your goal is to maximize performance during an experiment, not just analyze the results after. It's ideal for situations with a clear, immediate reward signal. Common uses include: first, dynamically allocating traffic in A/B/n tests to the best-performing variant; second, optimizing ad creatives or website headlines to maximize real-time clicks; third, personalizing content recommendations by balancing popular items with new discoveries.
WHEN NOT TO USE IT: Avoid bandits when you need to understand the performance of all variants with statistical confidence, including the losers. A classic, fixed-horizon A/B test is better for that. Bandits are also a poor fit if the reward signal is heavily delayed (e.g., a purchase that happens days after a click), as the algorithm needs rapid feedback to learn effectively.
ONE CANONICAL EXAMPLE: A news site is testing four headlines for an article. Instead of a rigid A/B/C/D test splitting traffic 25% each, it uses a bandit. Initially, traffic is split evenly. As Headline B starts getting more clicks, the bandit algorithm automatically allocates more traffic to it—say, 50%. It still allocates a small amount of traffic to A, C, and D to keep exploring, but it heavily favors the current winner to maximize total clicks while the article is popular.
Read the original → en.wikipedia.org
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.