Notes

UCB (Upper Confidence Bound)

Imagine choosing among several slot machines when you do not yet know which one pays best. UCB (Upper Confidence Bound) is a rule for making that choice: prefer actions that look rewarding, but give an extra boost to actions whose value is still uncertain. It turns exploration into a deliberate, quantitative decision rather than a random detour.

How the confidence bonus works

In the classic multi-armed bandit setting, UCB assigns each action an optimistic score:

UCB(a) = estimated_reward(a) + exploration_bonus(a)

A common version, UCB1, uses a bonus proportional to sqrt(2 log(t) / N(a)), where t is the total number of choices made and N(a) is how many times action a has been tried. An action tried only twice gets a large bonus; one tried thousands of times gets little extra credit. The learner selects the action with the highest combined score.

Optimism drives useful exploration

The “upper confidence bound” is an optimistic estimate: plausible uncertainty is treated as potential upside. This creates a practical balance:

  • Actions with high observed rewards remain attractive, supporting exploitation.
  • Poorly sampled actions receive attention while their true value is unclear, supporting exploration.
  • As evidence accumulates, uncertainty shrinks and the policy commits more strongly to the best action.

For example, if a recommender has shown one article 10,000 times and another only 5 times, UCB can test the second article even when its current average reward is slightly lower. Its small sample makes that average unreliable; it could be genuinely better.

Why it matters in reinforcement learning

Unlike epsilon-greedy, which explores by randomly overriding the current choice, UCB targets exploration where information is missing. In tabular reinforcement learning, an agent can add a UCB-style bonus to action-value estimates, encouraging visits to uncertain state–action pairs. This is especially valuable when rewards are sparse: random actions can waste many episodes, while uncertainty-guided actions systematically cover unknown territory. The guarantee behind UCB1 is also important: in stationary bandits, its regret grows only logarithmically with time. Its confidence calculations become harder with neural-network value estimates, nonstationary environments, or long delayed consequences, so methods such as Thompson sampling and intrinsic-reward exploration are also widely used.

UCB (Upper Confidence Bound) is a confidence-based exploration rule that selects the action with the highest plausible reward: its estimated value plus an uncertainty bonus that is larger for less-tried actions. The bonus shrinks as evidence accumulates, shifting behavior toward exploitation. UCB matters because it balances reward maximization with systematic exploration, avoiding premature commitment to actions whose values are uncertain.

Imagine choosing a restaurant. You could keep visiting your current favourite, or occasionally try somewhere new that might be even better. UCB, short for Upper Confidence Bound, is a rule for making that choice when learning by trial and reward.

It gives each option a “best plausible score.” Well-tested options earn credit for their known results. Less-tested options get a temporary boost because they might be better than they have had a chance to show. This helps a learning system avoid getting stuck with an early favourite while still choosing good options most of the time. It is a practical balance between enjoying what seems best and discovering what could be better.