Upper Confidence Bound Algorithms
Upper Confidence Bound algorithms handle the explore-versus-exploit tradeoff by always picking the option whose optimistic best-case estimate is currently highest, automatically favoring under-tried options until the data rules them out.
In a multi-armed bandit problem, you must repeatedly choose among options (arms) with unknown reward rates, balancing trying new options (exploration) against sticking with what's worked so far (exploitation). The Upper Confidence Bound (UCB) algorithm resolves this with one simple rule: always pick the arm whose optimistic upper estimate — its observed average reward plus a bonus for how little it's been tried — is currently the highest.
UCB scores each option as its average observed reward plus an uncertainty bonus that shrinks the more that option has been tried; picking the highest score each round means under-explored options get a temporary benefit of the doubt, and that benefit fades on its own as evidence accumulates, without ever needing a separate, tunable "exploration rate."
Why the bonus shrinks
The bonus term typically scales like , where is the total number of rounds so far and is how many times arm has been tried. As grows, the bonus shrinks toward zero, so a heavily-tried arm's score converges to its true observed average; an arm tried only once or twice keeps a large bonus, keeping it in contention until the data itself demotes it.
Worked example
Two ad variants are tested online. Variant A has been shown 100 times with an 8% average click rate; variant B has been shown only 5 times with a (noisy) 10% average click rate. Variant A's UCB score is roughly . Variant B's is roughly . Despite A's higher and more reliable average, B's larger uncertainty bonus wins out, so the algorithm shows B again next — exactly the exploration a naive "always pick the current best average" rule would have skipped.
UCB's guarantees assume the reward distribution for each arm is stationary — if the true reward rates drift over time (a common issue in ad serving or trading signals), a plain UCB algorithm can get stuck over-trusting an arm's stale historical average and needs a variant designed for non-stationary rewards instead.
Related concepts
Practice in interviews
Further reading
- Auer et al., 'Finite-time Analysis of the Multiarmed Bandit Problem'