Multi-Armed Bandits: Balancing Exploration and Exploitation

A multi-armed bandit algorithm balances exploiting a known winner with exploring new options to find a better one. It's used to dynamically test website headlines or ad copy, automatically shifting traffic to the best performer to maximize conversions.
WHY IT EXISTS Traditional A/B testing can be inefficient. You commit to a fixed test duration and sample size, knowingly sending half your traffic to a potentially inferior version. This costs you conversions. Multi-armed bandit algorithms were designed to solve this by minimizing "regret"—the lost value from not showing the best option—by dynamically optimizing during the test itself.
THE MENTAL MODEL Imagine you're at a casino with several slot machines, each a "one-armed bandit." Each has a different, hidden payout rate. Your goal is to maximize winnings. Do you keep playing the machine that has paid out the most so far (exploitation)? Or do you try other machines to see if they have a better payout rate (exploration)? A bandit algorithm is a formal strategy for making this decision at every step.
HOW IT WORKS A bandit algorithm begins by distributing traffic evenly across all variants to gather initial data (pure exploration). As it collects results (clicks, signups, etc.), it updates its confidence about which variant is the best. It then starts sending more traffic to the current leader (exploitation) while still allocating a small percentage to the other options to continue learning. This allows it to adapt if a different variant proves better over time. Different strategies, like Epsilon-Greedy or Thompson Sampling, manage this trade-off in slightly different ways.
WHEN TO USE IT Use a bandit approach for optimizing short-term campaigns, testing many variants at once (more than A/B), or for elements like headlines and ad copy where the goal is to maximize immediate performance. It finds a winner and exploits it quickly, rather than waiting for a formal test to conclude.
WHEN NOT TO USE IT Stick with a classic A/B test when you need high statistical confidence about why a variant won and by how much. Bandits are great at picking a winner, but because they alter traffic allocation, they make it difficult to get a clean, statistically significant measure of performance lift. Avoid them if the goal is deep analysis for a permanent change.
ONE CANONICAL EXAMPLE A media site wants to find the best headline for a breaking news story. It tests five headlines using a bandit algorithm. Initially, each gets 20% of the traffic. After 30 minutes, headline C has a much higher click-through rate. The algorithm shifts traffic so headline C now gets 70%, while the other four share the remaining 30%. This maximizes clicks while the story is popular, instead of waiting hours for an A/B test to declare a winner.
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.