Skip to content
AI360Xpert
Beta

Regret Bounds

Regret is the gap between the reward you got and the reward perfect play would have earned. Good learners make that gap grow slower than time itself.

Cumulative regret from a 10-pull two-arm trace stays at 0.9 while the square-root envelope bends below the linear never-learn line.
Cumulative regret from a 10-pull two-arm trace stays at 0.9 while the square-root envelope bends below the linear never-learn line.

Why Does This Exist?

Total reward alone cannot tell you whether an agent is learning. A slot machine that pays 0.4 per pull looks fine until you learn the machine next to it pays 0.7. The missing piece is the gap to perfect play, added up over time. That gap is regret, and a regret bound is a promise about how fast the gap grows.

This matters because exploration has a bill. Every pull of a worse arm, every episode with a shaky policy, pays it. Without a bound you cannot say whether multi-armed bandits algorithm A beats algorithm B, or whether your agent is improving or just lucky. With one, you get a number you can plot: linear means the agent never learns, sublinear means its average shortfall shrinks toward zero.

This page covers the definition, the two classic growth rates, and the optimism idea that earns them. Your prerequisites are the bandit setup and the upper confidence bound rule, plus the exploration versus exploitation tradeoff for motivation. The bandit page introduces regret in passing; the UCB page proves the bandit rate. Here you get the full picture and the lift from bandits to MDPs.

Think of It Like This

The new office lunch counters

You join an office with two lunch counters. Counter Best serves a meal worth 7 points to you. Counter Meh serves one worth 4 points. You do not know the scores yet, so you try both for ten days.

Each Meh day costs you 3 points of tastiness you could have had. That daily shortfall is instantaneous regret. Add it over ten days with three Meh visits and your cumulative regret is 9 points. The curve in the diagram is your lunch diary: it jumps by 3 on Meh days and stays flat on Best days.

A friend who never learns keeps picking at random and their diary climbs like a staircase forever. You learn: after day 6 you stop visiting Meh, your curve goes flat, and your average regret per day falls from 0.3 toward zero.

Where the analogy stops: lunch scores stay fixed and one meal never affects the next. In an MDP, today's action changes tomorrow's state, so regret has to compare whole policies from a start state, not single pulls. Delayed consequences make the bound carry extra factors for horizon, states, and actions.

How It Actually Works

The definition: cumulative regret

Fix KK episodes (or rounds), indexed by k=1k = 1 to KK. Let V⋆V^{\star} be the value of the optimal policy from the start state, meaning the best long-term return anyone could get. Let VπkV^{\pi_{k}} be the value of the policy the agent actually used in episode kk. Then cumulative regret is:

Regret(K)=∑k=1K(V⋆−Vπk)\mathrm{Regret}(K) = \sum_{k=1}^{K} \left( V^{\star} - V^{\pi_{k}} \right)

Every symbol in plain words: KK counts how long you played, V⋆V^{\star} is perfect play's score, πk\pi_{k} is what you did in episode kk, and each bracket term is what you left on the table that episode. In a bandit there is no state, so V⋆V^{\star} is the best arm's mean μ⋆\mu^{\star} and VπkV^{\pi_{k}} is the chosen arm's mean. The formula is the same shape, only simpler.

The headline test: regret is sublinear when Regret(K)/K\mathrm{Regret}(K) / K shrinks toward zero as KK grows. Put plainly, your average mistake per episode vanishes. Linear regret, say 0.3K0.3K, means you keep making the same mistake forever and never catch up.

Logarithmic versus square-root regret

Two regimes show up everywhere, and mixing them up causes real confusion.

Gap-dependent (logarithmic) bounds apply when the smallest gap Δ\Delta between the best and second-best option stays fixed above zero. Then a good algorithm needs only about log⁡K/Δ2\log K / \Delta^{2} pulls of each worse arm, and expected regret grows like log⁡K/Δ\log K / \Delta. The log⁡K\log K grows so slowly it looks almost flat: ln⁡(10)≈2.30\ln(10) \approx 2.30, ln⁡(1000)≈6.91\ln(1000) \approx 6.91, ln⁡(1000000)≈13.82\ln(1000000) \approx 13.82. I computed those three values directly. At a million episodes the log term is still under 14 while 1000000=1000\sqrt{1000000} = 1000. When gaps are fixed, logarithmic regret wins by a mile.

Gap-independent (square-root) bounds hold even when Δ\Delta can be tiny or shrink with KK. Then the worst-case price is on the order of K\sqrt{K} up to log factors. No algorithm beats that in general: when two arms differ by 1/K1 / \sqrt{K}, telling them apart takes about KK pulls, so K\sqrt{K} regret is unavoidable. Think of it as two promises. The log bound says life is cheap when answers are clear. The sqrt bound says learning still works when answers are murky, at a steeper but still sublinear price.

Our worked trace sits far under both at K=10K = 10, which is normal. Bounds describe growth, not tight small-KK predictions. The log bound's constants are loose early and the sqrt envelope sits high early; the payoff appears as KK grows and the curves bend while linear regret keeps climbing.

How optimism earns the bound

The engine behind both rates is optimism in the face of uncertainty. Keep a confidence interval around every estimate, then act as if the most favorable plausible world were true.

In bandits the upper confidence bound rule picks the arm maximizing sample mean plus bonus:

Ak=arg⁡max⁡a[Qk(a)+cln⁡kNk(a)]A_{k} = \arg\max_{a} \left[ Q_{k}(a) + c \sqrt{\frac{\ln k}{N_{k}(a)}} \right]

Here Qk(a)Q_{k}(a) is the average reward seen from arm aa so far, Nk(a)N_{k}(a) counts its pulls, kk is the round, and cc sets confidence width. The bonus shrinks each time you pull an arm and grows slowly with kk for arms you neglect, so no arm starves. A standard concentration argument shows each worse arm is pulled only O(log⁡K/Δ2)O(\log K / \Delta^{2}) times, and multiplying pulls by per-pull cost Δ\Delta gives O(log⁡K/Δ)O(\log K / \Delta) regret. Shrink Δ\Delta toward zero and the same argument degrades gracefully to the K\sqrt{K} rate.

The lift to MDPs keeps the same skeleton and pays for dynamics. Instead of one bonus per arm, optimistic algorithms keep confidence sets over rewards and transitions for each state-action pair, plan as if the best plausible model were true, act, then shrink the sets with fresh data. Early tabular versions do this with extended value iteration over the confidence set; later ones add an exploration bonus straight into the Bellman backup, roughly proportional to 1/N(s,a)1 / \sqrt{N(s, a)} where N(s,a)N(s, a) counts visits. The value estimates inside those backups are the same bootstrapped quantities temporal-difference learning computes, now with a bonus glued on. Regret keeps its definition, ∑k(V⋆−Vπk)\sum_{k}(V^{\star} - V^{\pi_{k}}), and the bound picks up the MDP size, growing with horizon, states, and actions under the square root plus log factors. That is the bandit-to-MDP lift: same optimism, wider uncertainty, heavier but still sublinear bill.

Worked 2-arm trace: gap 0.3 over 10 episodes

Two arms. Best pays mean μ⋆=0.7\mu^{\star} = 0.7, the other pays 0.40.4, so the gap is Δ=0.7−0.4=0.3\Delta = 0.7 - 0.4 = 0.3. Play K=10K = 10 episodes with this fixed pull order, writing 1 for a miss and 0 for the best arm:

[1,0,1,0,0,1,0,0,0,0][1, 0, 1, 0, 0, 1, 0, 0, 0, 0]

Instantaneous expected regret is 0.30.3 on a 1 and 00 on a 0. Accumulate it:

  • Episode 1 (miss): 0.30.3, cumulative 0.30.3.
  • Episode 2 (best): adds 00, cumulative stays 0.30.3.
  • Episode 3 (miss): adds 0.30.3, cumulative 0.60.6.
  • Episodes 4 to 5 (best, best): cumulative stays 0.60.6.
  • Episode 6 (miss): adds 0.30.3, cumulative 0.90.9.
  • Episodes 7 to 10 (best each time): cumulative stays 0.90.9.

Full trace: [0.3,0.3,0.6,0.6,0.6,0.9,0.9,0.9,0.9,0.9][0.3, 0.3, 0.6, 0.6, 0.6, 0.9, 0.9, 0.9, 0.9, 0.9]. Final regret 0.90.9, average regret 0.090.09 per episode. I computed every entry by hand and confirmed it with the script in the Code section.

Now compare against the two reference lines in the diagram, both computed for the same KK. The never-learn line pulls the worse arm every round: 0.3K0.3K, which is 3.03.0 at K=10K = 10. The drawn square-root envelope is 0.9k0.9\sqrt{k}, which is about 2.852.85 at K=10K = 10 since 10≈3.16\sqrt{10} \approx 3.16. Our trace ends at 0.90.9, under both. The two references cross exactly at k=9k = 9, where 0.9×3=2.70.9 \times 3 = 2.7 equals 0.3×9=2.70.3 \times 9 = 2.7. Before the crossing the sqrt curve rides higher; after it, the sqrt curve bends below the straight line. That bend is the whole visual argument: sublinear growth flattens while linear growth never does.

Code

This short script replays the exact trace above. Pull code 1 means the worse arm, 0 means the best arm. Run it and check the printed trace against the diagram's stepped line.

from typing import List

def cumulative_regret(pulls: List[int], mu_star: float, mu_sub: float) -> List[float]:    """Expected cumulative regret for a fixed pull order."""    gap = mu_star - mu_sub    total = 0.0    trace: List[float] = []    for a in pulls:        if a == 1:            total += gap        trace.append(round(total, 2))    return trace

pulls = [1, 0, 1, 0, 0, 1, 0, 0, 0, 0]trace = cumulative_regret(pulls, 0.7, 0.4)print(trace)print("final:", trace[-1], "average:", round(trace[-1] / len(trace), 4))
# -> expected output:[0.3, 0.3, 0.6, 0.6, 0.6, 0.9, 0.9, 0.9, 0.9, 0.9]final: 0.9 average: 0.09

Watch Out For

Sublinear is not zero regret

A flat-looking curve can still hide a big bill. Our trace ends at 0.9 after 10 episodes, which is 0.09 per episode of missed value. Sublinear only promises the per-episode average keeps shrinking as episodes grow, not that early regret was small. The fix: always quote regret with its horizon. Say 0.9 after 10 episodes and report the average 0.09 alongside it. Never compare one paper's 900 against another's 90 when their horizons differ by a factor of 100.

The horizon and the MDP size ride along

Bandit intuition understates MDP regret. Each extra horizon step, state, or action widens the confidence sets, so the same bonus that explores a 2-arm bandit in 10 pulls can take orders of magnitude longer in a long-horizon MDP. Symptom: a bonus tuned on bandits stalls in gridworlds because rarely visited state-action pairs stay overconfident. The fix: keep the horizon fixed when comparing curves, normalize regret per episode, and expect the bound to grow with horizon, states, and actions under the root rather than staying a pure function of episode count.

The Quick Version

  • Cumulative regret is the total shortfall to perfect play: the sum over episodes of optimal value minus the value of the policy actually used.
  • Regret is sublinear when average regret per episode shrinks toward zero, which is the precise meaning of an agent that keeps learning.
  • A fixed gap between best and rest gives logarithmic regret like UCB achieves in bandits, while tiny or shrinking gaps cost square-root regret in the worst case.
  • Optimism earns both rates by acting on the best plausible estimates and shrinking confidence intervals with each visit, from bandit bonuses to MDP-wide optimistic planning.
  • Our 2-arm trace with gap 0.3 and three misses in 10 episodes ends at regret 0.9, sitting below the 2.85 square-root envelope and the 3.0 never-learn line.