Inferensys

Glossary

Multi-Armed Bandit

A multi-armed bandit is a sequential decision-making framework where an agent must balance exploring unknown actions with exploiting the best-known action to maximize cumulative reward.
Developer demonstrating multi-agent tool use, agent tool selection interface on laptop, casual tech demo moment.
ONLINE LEARNING ARCHITECTURE

What is a Multi-Armed Bandit?

A foundational sequential decision-making framework for balancing exploration and exploitation in uncertain environments.

A multi-armed bandit is a sequential decision-making framework where an agent must repeatedly choose between multiple actions (arms) with unknown reward distributions to maximize cumulative reward over time. The core challenge is the explore-exploit tradeoff: balancing the gathering of new information about uncertain arms with leveraging the best-known arm. This framework is fundamental to online experimentation, recommendation systems, and clinical trials, where decisions must be made with incomplete information.

Algorithms like Upper Confidence Bound (UCB) and Thompson Sampling provide principled strategies for this tradeoff. UCB selects actions based on an optimistic estimate of their potential reward, while Thompson Sampling uses a Bayesian approach, sampling from posterior distributions. The performance of these algorithms is formally analyzed through regret minimization, which measures the difference between the agent's cumulative reward and the reward of the best fixed action in hindsight.

ALGORITHMIC FOUNDATIONS

Core Multi-Armed Bandit Algorithms

These are the principal algorithms used to solve the multi-armed bandit problem, each implementing a distinct strategy for balancing exploration and exploitation to minimize cumulative regret.

01

Epsilon-Greedy

The Epsilon-Greedy algorithm is a simple, fundamental strategy where, with probability 1-ε, the agent exploits the arm with the highest current estimated reward, and with probability ε, it explores a random arm uniformly. It provides a direct, tunable knob for the explore-exploit tradeoff.

  • Key Parameter: ε (epsilon), the exploration rate.
  • Advantages: Simple to implement and understand; computationally inexpensive.
  • Limitations: Explores uniformly, ignoring which arms are more promising; exploration rate is fixed and does not adapt to uncertainty.
  • Typical Use: Baseline algorithm for A/B testing platforms and simple recommendation systems.
02

Upper Confidence Bound (UCB)

The Upper Confidence Bound (UCB) family of algorithms selects the arm with the highest upper confidence bound on its reward, calculated as the current sample mean plus an exploration bonus. The bonus is proportional to the uncertainty (variance) of the estimate, shrinking as an arm is pulled more often.

  • Core Principle: Optimism in the face of uncertainty. It assumes the best plausible reward for each arm.
  • Mathematical Form: Common variants include UCB1, which uses a bonus term derived from the Chernoff-Hoeffding bound: mean + sqrt(2 * log(total_pulls) / arm_pulls).
  • Advantages: Deterministic, no hyperparameters like ε; provides strong theoretical regret bounds.
  • Use Case: Clinical trial designs, web page optimization where deterministic action selection is preferred.
03

Thompson Sampling

Thompson Sampling is a Bayesian algorithm that selects actions by sampling from the posterior probability distribution that each arm is optimal. For each decision, it draws a sample reward estimate from each arm's posterior and pulls the arm with the highest sampled value.

  • Mechanism: Maintains a prior distribution (e.g., Beta for Bernoulli rewards, Gaussian for normal rewards) for each arm's reward. After observing a reward, it updates the posterior via Bayes' rule.
  • Natural Balance: Arms with high uncertainty have wider posteriors, leading to a higher chance of being sampled, automatically balancing exploration and exploitation.
  • Advantages: Often achieves lower empirical regret than UCB; elegantly incorporates prior knowledge.
  • Use Case: The dominant algorithm for modern large-scale recommendation systems and online advertising.
04

EXP3 (Adversarial Bandits)

The Exponential-weight algorithm for Exploration and Exploitation (EXP3) is designed for the adversarial bandit setting, where an opponent may generate rewards arbitrarily (not from a stationary distribution). It maintains a weight for each arm and selects actions probabilistically based on these weights, which are updated using an exponential function of the observed reward.

  • Key Feature: Makes minimal assumptions about the environment, providing robustness against non-stationary or malicious reward sequences.
  • Mechanism: Uses importance sampling to estimate rewards for unchosen arms, then updates weights to favor higher-rewarding actions.
  • Trade-off: While robust, it typically has higher regret than stochastic algorithms like UCB or Thompson Sampling in benign, stationary environments.
  • Use Case: Cybersecurity (e.g., selecting defensive actions against an adaptive attacker), dynamic pricing against strategic competitors.
05

LinUCB (Contextual Bandits)

LinUCB extends the UCB principle to contextual bandits, where side information (context) is available before each decision. It assumes a linear relationship between the context vector and the expected reward of each arm.

  • Model: For each arm a, it models the expected reward as θ_a^T * x, where x is the context and θ_a are learnable parameters. It maintains confidence ellipsoids around these parameter estimates.
  • Action Selection: Chooses the arm that maximizes x^T * θ_a + α * sqrt(x^T * A_a^{-1} * x), where the second term is a confidence width derived from the ridge regression solution.
  • Advantages: Enables personalization by leveraging user/context features; has strong theoretical guarantees.
  • Use Case: News article recommendation, personalized healthcare interventions, and any application where rich feature vectors describe each decision opportunity.
06

Bayesian UCB

Bayesian UCB is a hybrid approach that uses a Bayesian model (like Thompson Sampling) to compute a credible interval for each arm's reward, then applies the UCB principle by selecting the arm with the highest upper quantile of its posterior distribution (e.g., the 95th percentile).

  • Mechanism: It combines Bayesian updating for parameter estimation with a deterministic, optimistic decision rule.
  • Flexibility: Can use any tractable posterior distribution (Beta, Gaussian, etc.). The quantile level (e.g., 95%) acts as a hyperparameter controlling optimism.
  • Comparison to Thompson Sampling: More deterministic; can be easier to analyze theoretically. Comparison to Frequentist UCB: Uses a probabilistically interpretable uncertainty measure from the posterior.
  • Use Case: Problems where deterministic action selection is required but a Bayesian model of uncertainty is desired, such as in some financial trading applications.
EXPERIMENTATION STRATEGIES

Multi-Armed Bandit vs. Traditional A/B Testing

A comparison of two core methodologies for online experimentation, highlighting their operational mechanics, resource allocation, and suitability for different business contexts.

Feature / MetricTraditional A/B TestingMulti-Armed Bandit

Core Objective

Statistical validation of a hypothesis

Maximization of cumulative reward

Allocation Strategy

Fixed, equal traffic split for the duration

Dynamic, adaptive traffic allocation based on performance

Primary Trade-off

Statistical power vs. experiment duration

Exploration of options vs. exploitation of the best

Traffic Re-allocation

None during the experiment

Continuous, often after every user interaction

Primary Metric

Statistical significance (p-value)

Cumulative regret or total reward

Optimal Use Case

Final validation of major changes with a clear winner

Optimizing continuous metrics (CTR, conversion) with many variants

Learning During Experiment

No; analysis occurs only after data collection

Yes; the algorithm learns and adapts in real-time

Risk of Opportunity Cost

High; suboptimal variants receive equal traffic

Low; traffic shifts toward better-performing variants

Typical Experiment Duration

Fixed, pre-determined (e.g., 2 weeks)

Indefinite; can run continuously as an adaptive system

Result Interpretation

Declare a 'winner' based on significance

Identify a continuously evolving 'best' arm; may not declare a final winner

MULTI-ARMED BANDIT

Frequently Asked Questions

A multi-armed bandit is a sequential decision-making framework where an agent must balance exploring unknown actions with exploiting the best-known action to maximize cumulative reward, fundamental to online experimentation and recommendation systems.

A multi-armed bandit is a sequential decision-making framework where an agent must repeatedly choose between multiple actions ("arms") to maximize cumulative reward over time, while balancing the exploration of uncertain options with the exploitation of the best-known option. The name is an analogy to a gambler facing a row of slot machines ("one-armed bandits"), each with an unknown probability of payout. The agent's goal is to minimize regret—the difference between the reward obtained and the reward that would have been obtained by always choosing the optimal arm. This framework is foundational to online learning systems like adaptive clinical trials, real-time recommendation engines, and automated A/B testing platforms.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.