RL Note 2: Multi-Armed Bandits

16 min read Page Views
Table of Contents

Prologue

In the last post, we introduced the basics of RL—action, reward, state, value, policy, model, etc.—so you should now have a rough picture of the field. In this post, we go deeper and discuss a classic yet still active topic: Multi-Armed Bandits (MAB). There will be more math ahead; hope you can enjoy it.

Problem Formulation

Multi-armed bandits are popular gambling games. There are slot machines, each called a bandit, with an unknown reward distribution that governs how much you get when pulling its arm. Your goal is to maximize the total winnings within a fixed number of pulls. You may try the game to get an intuition at https://su-my.github.io/Test-page. mab

Let’s abstract the gambling game to a formal problem definition:

Definition: Stochastic Multi-Armed Bandit(MAB) Problem
Let A={a1,a2,…,aK}\mathcal{A} = \{ a_1, a_2, \dots, a_K \} be the set of arms. Pulling arm aka_k at round tt yields a reward Rt,k∼DkR_{t,k} \sim \mathcal{D}_k, where each Dk\mathcal{D}_k is an unknown distribution with mean μk\mu_k. Over a finite horizon TT, a policy chooses arms (ai1,…,aiT)(a_{i_1}, \dots, a_{i_T}) and observes rewards (R1,i1,…,RT,iT)(R_{1,i_1}, \dots, R_{T,i_T}). The objective is to maximize the expected cumulative reward Eπ[∑t=1TRt,it]\mathbb{E}_\pi\left[\sum_{t=1}^{T} R_{t,i_t}\right].

where the RiR_i notations are random variabes for rewards.

Furthur discussions:

Regret

Definitions

Regret is the primary metric for evaluating a MAB algorithm. Informally, it is the gap between the reward you would obtain by always pulling the best arm and the reward actually obtained by the algorithm. A smaller regret indicates a better algorithm.

Throughout this section we assume a stochastic environment with arm-wise reward means {μk}k=1K\{\mu_k\}_{k=1}^K, and we write μ∗=max⁡1≤k≤Kμk\mu^* = \max\limits_{1\le k\le K} \mu_k for the optimal mean.

Definition: Realized Pseudo-Regret

Fix a policy π\pi and a sample path ω=(ai1,ai2,…,aiT)∈Ω\omega=(a_{i_1}, a_{i_2},\dots,a_{i_T})\in\Omega.
Let At:Ω→AA_t:\Omega\to\mathcal{A} denote the random arm chosen at round tt, and write At(ω)=aitA_t(\omega)=a_{i_t} for its realization along ω\omega.
The realized pseudo-regret at horizon TT is

Rπ(T,ω)=∑t=1T(μ∗−μ(At(ω)))=Tμ∗−∑t=1Tμit. \mathbf R_\pi(T,\omega) = \sum_{t=1}^T \bigl(\mu^* - \mu(A_t(\omega))\bigr) = T\mu^* - \sum_{t=1}^T \mu_{i_t}.
Definition: Random Pseudo-Regret

Under policy π\pi, the (trajectory-dependent) random pseudo-regret is the random variable

Rπ(T)=∑t=1T(μ∗−μ(At))=Tμ∗−∑t=1Tμ(At), \mathbf R_\pi(T) = \sum_{t=1}^T \bigl(\mu^* - \mu(A_t)\bigr) = T\mu^* -\sum_{t=1}^T\mu(A_t),

It represents the regret as a random variable before taking expectation.

Definition: Expected Pseudo-Regret

The expected pseudo-regret of policy π\pi is

Rπ(T)=Eπ[Rπ(T)]=∫ΩRπ(T,ω) dPπ(ω), R_{\pi}(T) = \mathbb{E}_\pi[\mathbf R_\pi(T)] = \int_\Omega \mathbf R_\pi(T,\omega)\,d\mathbb{P}_\pi(\omega),

which measures the algorithm’s average performance under its induced randomness.

The three regret notions above may look verbose, but they separate measurables cleanly and avoid mixing pathwise quantities with expectations1. Two remarks:

  1. Why pseudo-regret?
    Pseudo‑regret replaces realized rewards by their means. It isolates the algorithm’s decision quality from observation noise. A corresponding “real” (pathwise) regret can be defined by using realized rewards. Let a∗∈arg⁡max⁡kμka^*\in\arg\max_k \mu_k and let rt(a)r_t(a) denote the realized reward at round tt if arm aa were pulled. Then the realized regret along ω\omega is

    Rπreal(T,ω)=∑t=1T(rt(a∗)−rt(At(ω))). \mathbf R^{\mathrm{real}}_\pi(T,\omega) = \sum_{t=1}^T \bigl(r_t(a^*) - r_t(A_t(\omega))\bigr).

    Taking expectation over the reward noise (with rt(a)∼Dar_t(a)\sim\mathcal D_a) recovers the pseudo‑regret:

    E[Rπreal(T,ω)∣A1(ω),…,AT(ω)]=Rπ(T,ω). \mathbb E\bigl[\mathbf R^{\mathrm{real}}_\pi(T,\omega)\mid A_1(\omega),\dots,A_T(\omega)\bigr] = \mathbf R_\pi(T,\omega).

    In analysis we usually work with pseudo‑regret, and when context is clear we simply say “regret”.

  2. Why is AtA_t random?
    Because both the rewards and the policy may be stochastic. Rewards influence the history observed by the policy, and the policy may randomize given that history; therefore At:Ω→AA_t:\Omega\to\mathcal A is a random variable.

Lower Bounds

For convenience, we only talk about the realized regret under a fixed trajectory ω\omega and a fixed policy π\pi and simplify the Rπ(T,ω)\mathbf {R}_\pi(T,\omega) as R(T)\mathbf R(T).

As mentioned before, we should make the regret grow slower. So what is the lower bound for regret?

It’s easy to find out any algorithm cannot be worse than linear, since:

R(T)=∑t=1T(μ∗−μ(At(ω)))≤∑t=1T(μ∗−μ′)=TΔ=Ω(T) \begin{aligned} \mathbf R(T) &= \sum_{t=1}^T\left(\mu^*-\mu(A_t(\omega))\right) \\ & \leq \sum_{t=1}^T\left(\mu^*-\mu'\right) \\ & = T\Delta \\ &= \Omega(T) \end{aligned}

where μ′=min⁡1≤k≤Kμk,Δ=μ∗−μ′\mu' = \min\limits_{1\le k\le K} \mu_k, \Delta = \mu^*-\mu'.

Hence, a wise algorithm should be sub-linear, i.e. o(T)o(T). Two common lower bounds are:

  • Gap-independent:

    Ω(TK) \Omega(\sqrt{TK})
  • Gap-dependent:

    Ω(∑ai≠a∗(ΔiKL(Pai,Pa∗))log⁡T) \Omega\left(\sum_{a_i \ne a^*} \left( \frac{\Delta_i}{KL(P_{a_i}, P_{a^*})} \right) \log T\right)

where KK is the number of arms; Δi\Delta_i is the gap between the mean of a∗a_* and aia_i; the gap-independent means it’s hard to identify the gap between the arms; gap-dependent is the opposite.

Intuitively, the easier the gap is to indentify, the less attention will be paid to find out the best arm and we will get lower regret. That’s why the gap-dependent lower bound is Ω(log⁡T)\Omega(\log T) which is less than Ω(T)\Omega(\sqrt{T})

Proofs will be provided once I figured them out.

Explore-Exploit Dilemma

The difficulty of MAB comes from the explore-exploit dilemma, which is intuitive once you get to know what MAB problems are chasing for.

  • Explore: we must pay some steps to explore the best policy for choosing among arms to avoid commiting to the wrong arms causing linear regrets later. But the exploration phase is always along with regret accumulation itself because of the wrong attempts we must meet.
  • Exploit: Stick to current policy. As talked before, this may leads to high regret if the exploration is not sufficient.

MAB From the Perspective of RL

As the broad picture you may have for MAB now, it’s just a RL-like problem with simplified environments. You may treat the reward in MAB as a combination of observation and reward in RL. mab in rl

Tail Bounds2

To get into the real discussion of MAB, we first state a few mathematical propositions that describe how far samples of a random variable can deviate from its expectation. This is necessary for further analysis of MAB algorithms since we are estimating the means μk\mu_k; if we can estimate these means accurately and quickly, we can obtain low regret.

If you are not interested in the math details, you can jump to Hoeffding’s Inequality and skip this section omitting all proofs.

Markov’s Inequality

Proposition: Markov’s Inequality
Pr⁡(X≥a)≤E(X)a \Pr(X\ge a)\le \frac{\mathbb E(X)}{a}

where XX is a non-negative random variable.

Proof: Markov’s Inequality

Consider the indicator function for X≥aX\ge a:

1{X≥a}={1X≥a0X<a \mathbf 1_{\{X\ge a\}} = \begin{cases} 1 & X\ge a \\ 0 & X < a \end{cases}

By the definition of expectation, E[1{X≥a}]=Pr⁡(X≥a)\mathbb E\bigl[\mathbf 1_{\{X\ge a\}}\bigr] = \Pr(X\ge a).

If X<aX < a, then 1{X≥a}=0\mathbf 1_{\{X\ge a\}}=0 and X≥0=a 1{X≥a}X\ge 0 = a\,\mathbf 1_{\{X\ge a\}}; if X≥aX\ge a, then 1{X≥a}=1\mathbf 1_{\{X\ge a\}}=1 and X≥a=a 1{X≥a}X\ge a = a\,\mathbf 1_{\{X\ge a\}}. Thus X≥a 1{X≥a}X\ge a\,\mathbf 1_{\{X\ge a\}} always holds.

Taking expectations on both sides yields

E(X)≥a E[1{X≥a}]=a Pr⁡(X≥a), \mathbb E(X)\ge a\,\mathbb E\bigl[\mathbf 1_{\{X\ge a\}}\bigr] = a\,\Pr(X\ge a),

i.e.

Pr⁡(X≥a)≤E(X)a. \Pr(X\ge a)\le \frac{\mathbb E(X)}{a}.

□\square

Chebyshev’s Inequality

Proposition: Chebyshev’s Inequality
Pr⁡(∣X−μ∣≥kσ)≤1k2,for any k>0, \Pr(\lvert X-\mu\rvert\ge k\sigma)\le\frac{1}{k^2},\quad \text{for any } k>0,

where μ\mu is the expectation of XX, and σ\sigma is the standard deviation of XX.

Proof: Chebyshev’s Inequality

Using Markov’s inequality, we have:

Pr⁡(∣X−μ∣≥kσ)=Pr⁡(∣X−μ∣2≥k2σ2)≤E[(X−μ)2]k2σ2=1k2, \begin{aligned} \Pr(\lvert X-\mu\rvert\ge k\sigma) & = \Pr(\lvert X-\mu\rvert^2\ge k^2\sigma^2)\\ & \le\frac{\mathbb E\bigl[(X-\mu)^2\bigr]}{k^2\sigma^2} \\ & = \frac{1}{k^2}, \end{aligned}

where the last equality uses Var⁡(X)=E[(X−μ)2]=σ2\operatorname{Var}(X)=\mathbb E\bigl[(X-\mu)^2\bigr]=\sigma^2. □\square

Chernoff Bound

The Chernoff bound is a technique to estimate tail bounds quantitatively, i.e., Pr⁡(X≥a)\Pr(X\ge a) or Pr⁡(X≤a)\Pr(X\le a). We can summarize it in three steps:

Chernoff Bound Trick Steps
  1. For t∈Rt\in\mathbb R, apply the map x↦etxx\mapsto e^{tx} to obtain Pr⁡(etX≥eta)\Pr(e^{tX}\ge e^{ta}). When t>0t>0 this bounds the upper tail Pr⁡(X≥a)\Pr(X\ge a); when t<0t<0 it bounds the lower tail Pr⁡(X≤a)\Pr(X\le a). This ensures the random variable etXe^{tX} is non‑negative so Markov’s inequality applies.
  2. Apply Markov’s inequality: Pr⁡(etX≥eta)≤e−ta E[etX].\Pr(e^{tX}\ge e^{ta})\le e^{-ta}\,\mathbb E\bigl[e^{tX}\bigr].
  3. Choose tt to make the right‑hand side as small as possible (optimize over tt): Pr⁡(X≥a)≤inf⁡t>0e−taMX(t),Pr⁡(X≤a)≤inf⁡t<0e−taMX(t),\Pr(X\ge a)\le \inf\limits_{t>0} e^{-ta} M_X(t),\quad \Pr(X\le a)\le \inf\limits_{t<0} e^{-ta} M_X(t), where MX(t)=E[etX]M_X(t)=\mathbb E\bigl[e^{tX}\bigr] is the moment generating function (MGF) of XX.

As an illustration, consider Bernoulli trials and apply the Chernoff bound.

Suppose we have nn i.i.d. Bernoulli trials XiX_i with success probability pp. Let X=∑iXiX=\sum_i X_i; then μ=E[X]=np\mu = \mathbb E[X]=np. Suppose λ>1\lambda > 1.

Pr⁡(X≥λμ)≤inf⁡t>0e−tλnp E[etX]=inf⁡t>0e−tλnp ∏i=1nE[etXi]=inf⁡t>0e−tλnp (pet+1−p)n=inf⁡t>0exp⁡(nlog⁡(pet+1−p)−tλnp) \begin{aligned} \Pr(X\ge \lambda\mu)&\le \inf\limits_{t>0} e^{-t\lambda np}\,\mathbb E\bigl[e^{tX}\bigr]\\ &=\inf\limits_{t>0} e^{-t\lambda np}\, \prod_{i=1}^n \mathbb E\bigl[e^{tX_i}\bigr]\\ &=\inf\limits_{t>0} e^{-t\lambda np}\, (pe^t+1-p)^n \\ &=\inf\limits_{t>0} \exp\bigl(n\log (pe^t+1-p)-t\lambda np\bigr) \end{aligned}

Consider the function f(t)=nlog⁡(pet+1−p)−tλnpf(t) = n\log (pe^t+1-p)-t\lambda np. Taking the derivative and setting it to 00, we have

f′(t)=npetpet+1−p−λnp=0f'(t) = \frac{npe^t}{pe^t+1-p}-\lambda np = 0

i.e.,

t∗=log⁡λ+log⁡(1−p)−log⁡(1−λp).t^*=\log \lambda+\log(1-p)-\log(1-\lambda p).

It is easy to verify that f(t)f(t) attains its minimum at t∗t^*. Substituting t∗t^* into f(t)f(t), we have

f(t∗)=−n((1−λp)log⁡1−λp1−p+λplog⁡λ)=−n DKL(λp∥p), f(t^*) = -n\left((1-\lambda p)\log \frac{1-\lambda p}{1-p}+\lambda p \log \lambda\right) = -n\,D_{\text{KL}}(\lambda p \parallel p),

where DKL(q∥p)=qlog⁡ ⁣qp+(1−q)log⁡ ⁣1−q1−pD_{\text{KL}}(q\parallel p)= q\log\!\frac{q}{p} + (1-q)\log\!\frac{1-q}{1-p} is the Kullback–Leibler divergence between Bernoulli parameters.

t∗>0t^* > 0 since λ>1\lambda > 1. Hence, we have

Pr⁡(X≥λμ)≤exp⁡(−n DKL(λp∥p)). \Pr(X\ge \lambda\mu)\le \exp\bigl(-n\,D_{\text{KL}}(\lambda p \parallel p)\bigr).

Hoeffding’s Inequality

The protagonist finally comes! The Hoeffding’s inequality are bounding a set of independent bounded random variables. You may find it especially useful in MAB problems since the arms are basically a set of independent random variables.

Hoeffding’s Inequality is actually a special case of Chernoff Bound. Let’s give the proposition first:

Proposition: Hoeffding’s Inequality

Given a set of independent bounded random varibales {Xi}i=1n\left\{X_i\right\}_{i=1}^n with Xi∈[ai,bi]X_i\in[a_i,b_i]. Let X=∑iXiX=\sum_i X_i and μ=E[X]\mu=\mathbb E[X]. Then

Pr⁡(X−μ≥ε)≤exp⁡(−2ε2∑i=1n(bi−ai)2) \Pr(X-\mu\ge \varepsilon)\le \exp\left(-\frac{2\varepsilon^2}{\sum_{i=1}^n (b_i-a_i)^2}\right)

or

Pr⁡(X−μ≤−ε)≤exp⁡(−2ε2∑i=1n(bi−ai)2) \Pr(X-\mu\le -\varepsilon)\le \exp\left(-\frac{2\varepsilon^2}{\sum_{i=1}^n (b_i-a_i)^2}\right)

It’s easy to find out the Hoeffding’s inequality is a special case of Chernoff Bound.

Proof: Hoeffding’s Inequality

Let μi=E[Xi]\mu_i = \mathbb E[X_i], ε>0\varepsilon > 0. Then

Pr⁡(X−μ≥ε)≤inf⁡t>0e−tε E[et(X−μ)]=inf⁡t>0e−tε E[et∑i=1n(Xi−μi)]=inf⁡t>0e−tε ∏i=1nE[et(Xi−μi)] \begin{aligned} \Pr(X-\mu\ge \varepsilon)&\le \inf\limits_{t>0} e^{-t\varepsilon}\,\mathbb E\left[e^{t(X-\mu)}\right]\\ &=\inf\limits_{t>0} e^{-t\varepsilon}\, \mathbb E\left[e^{t\sum_{i=1}^n(X_i-\mu_i)}\right]\\ &=\inf\limits_{t>0} e^{-t\varepsilon}\, \prod_{i=1}^n \mathbb E\left[e^{t(X_i-\mu_i)}\right] \end{aligned}

According to Hoeffding’s Lemma, we have

E[et(Xi−μi)]≤exp⁡(t2(bi−ai)28) \mathbb E\left[e^{t(X_i-\mu_i)}\right]\le \exp\left(\frac{t^2(b_i-a_i)^2}{8}\right)

Hence

Pr⁡(X−μ≥ε)≤inf⁡t>0e−tε ∏i=1nexp⁡(t2(bi−ai)28)=inf⁡t>0exp⁡(−tε+t28∑i=1n(bi−ai)2)=exp⁡(−ε22∑i=1n(bi−ai)2) \begin{aligned} \Pr(X-\mu\ge \varepsilon)&\le \inf\limits_{t>0} e^{-t\varepsilon}\, \prod_{i=1}^n \exp\left(\frac{t^2(b_i-a_i)^2}{8}\right)\\ &=\inf\limits_{t>0} \exp\left(-t\varepsilon+\frac{t^2}{8}\sum_{i=1}^n (b_i-a_i)^2\right) \\ &=\exp\left(-\frac{\varepsilon^2}{2\sum_{i=1}^n (b_i-a_i)^2}\right) \end{aligned}

The last equality is taken when t=4ε∑i=1n(bi−ai)2t=\frac{4\varepsilon}{\sum_{i=1}^n (b_i-a_i)^2} □\square

We used Hoeffding’s Lemma to bound the MGF of Xi−μiX_i-\mu_i:

Hoeffding’s Lemma

Let X∈[a,b]X\in[a,b] and μ=E[X]\mu=\mathbb E[X]. Then ∀t∈R\forall t \in \mathbb R

E[et(X−μ)]≤exp⁡(t2(b−a)28) \mathbb E\left[e^{t(X-\mu)}\right]\le \exp\left(\frac{t^2(b-a)^2}{8}\right)
Proof: Hoeffding’s Lemma

Consider Y = X−μX-\mu, then E[Y]=0\mathbb E[Y] = 0 Since etYe^{tY} is convex, we have:

etY=b−Yb−aeta+Y−ab−aetb e^{tY} = \frac{b-Y}{b-a}e^{ta} + \frac{Y-a}{b-a}e^{tb}

Take expectation on both sides, we have

E[etY]=bb−aeta−ab−aetb \mathbb E\left[e^{tY}\right] = \frac{b}{b-a}e^{ta} - \frac{a}{b-a}e^{tb}

Let u=t(b−a)u=t(b-a) and λ=−ab−a\lambda = \frac{-a}{b-a}, then

E[etY]=e−λu(1−λ+λeu)=exp⁡(−λu+log⁡(1−λ+λeu)) \mathbb E\left[e^{tY}\right] = e^{-\lambda u} \left(1-\lambda + \lambda e^{u}\right) = \exp\left(-\lambda u + \log \left(1-\lambda+\lambda e^{u}\right)\right)

Consider g(u)=−λu+log⁡(1−λ+λeu)g(u)=-\lambda u + \log \left(1-\lambda+\lambda e^{u}\right), it’s easy to verify g(0)=g′(0)=0g(0) = g'(0) = 0.

And g′′(u)=(1−λ)λeu(1−λ+λeu)2≤14g''(u) = \frac{(1-\lambda)\lambda e^u}{(1-\lambda+\lambda e^{u})^2}\le\frac{1}{4} R_{\operatorname{ETC}(m)} (n) \le m\sum_{i=2}^k\Delta_i + (n-mk)\sum_{i=2}^k\exp\left(-\frac{m\Delta_i^2}{4}\right)

Hence ∃ξ∈(0,u)\exist \xi\in(0,u) s.t. g(u)=g(0)+g′(0)u+12g′′(ξ)u2≤u28g(u) = g(0) + g'(0)u + \frac{1}{2}g''(\xi)u^2 \le \frac{u^2}{8}

Which means E[etY]≤exp⁡(u28)\mathbb E\left[e^{tY}\right]\le \exp\left(\frac{u^2}{8}\right)

□\square

Let’s also give a special case of Hoeffding’s Inequality here when all random variables are i.i.d. and sub-gaussian.

Hoeffding’s Inequality for i.i.d. sub-gaussian random variables

Let X1,…,XnX_1,\ldots,X_n be i.i.d. sub-gaussian random variables with sub-gaussian norm σ\sigma, which means

E[et(Xi−μ)]≤exp⁡(t2σ22) \mathbb E\left[e^{t(X_i-\mu)}\right]\le \exp\left(\frac{t^2\sigma^2}{2}\right)

Let Xˉ=1n∑i=1nXi\bar X=\frac{1}{n}\sum_{i=1}^n X_i and μ=E[Xˉ]\mu=\mathbb E[\bar X]. Then

Pr⁡(∣Xˉ−μ∣≥ε)≤2exp⁡(−nε22σ2) \Pr(\lvert\bar X-\mu\rvert\ge \varepsilon)\le 2\exp\left(-\frac{n\varepsilon^2}{2\sigma^2}\right)
Proof: Hoeffding’s Inequality for i.i.d. sub-gaussian random variables

The both sides are symmetric. Let’s prove the case Pr⁡(Xˉ−μ≥ε)\Pr(\bar X-\mu\ge \varepsilon).

It’s easy to verify that Xˉ\bar X is also sub-gaussian with sub-gaussian norm σn\frac{\sigma}{\sqrt{n}} and .

Pr⁡(Xˉ−μ≥ε)=Pr⁡(et(Xˉ−μ)≥etε)=inf⁡t>0e−tε E[et(Xˉ−μ)]≤inf⁡t>0exp⁡(−tε+t2σ22n)=exp⁡(−nε22σ2) \begin{aligned} \Pr(\bar X -\mu\ge\varepsilon) &= \Pr(e^{t(\bar X-\mu)}\ge e^{t\varepsilon}) \\ & = \inf\limits_{t>0} e^{-t\varepsilon}\,\mathbb E\left[e^{t(\bar X-\mu)}\right] \\ & \le \inf\limits_{t>0} \exp\left(-t\varepsilon + \frac{t^2\sigma^2}{2n}\right) \\ & = \exp\left(-\frac{n\varepsilon^2}{2\sigma^2}\right) \end{aligned}

Explore-Then-Commit

Explore-Then-Commit (ETC) is an intuitive algorithm for MAB problems. It pulls each arm a fixed number of times, then commits to the arm with the highest estimated mean.

Definition: Explore-Then-Commit Algorithm

Given the following environment:

  • kk: number of arms
  • nn: horizon, n>kn > k
  • A={ai}i=1k\mathcal A = \{a_i\}_{i=1}^{k}

The arm chosen at round tt is:

At={(tmod  k)+1t≤mkarg max⁡a∈Aμ^at>mk A_t = \begin{cases} (t\mod k) + 1 & t\le mk \\ \argmax_{a\in\mathcal A} \hat \mu_a & t > mk \end{cases}

where m<⌊nk⌋m<\lfloor\frac{n}{k}\rfloor is the number of times each arm is pulled and μ^a=1m∑i=1mra,i\hat \mu_a=\frac{1}{m}\sum_{i=1}^m r_{a,i}, with ra,ir_{a,i} the reward of arm aa on its ii-th pull. Tie-breaking of arg max⁡\argmax is usually random.

Consider the special case where all arms are 11-sub-Gaussian; this helps build intuition for the regret. For brevity, we denote the expected pseudo-regret of ETC at horizon nn by RETC(n)R_{\mathrm{ETC}}(n).

W.l.o.g., assume ∀i<j,μi≥μj\forall i < j, \mu_i \ge \mu_j, and define Δi=μ1−μi\Delta_i = \mu_1 - \mu_i.

RETC⁡(m)(n)=E[∑i=1nΔAi]=∑i=1n∑j=1kPr⁡(Ai=j)Δj=m∑i=2kΔi+(n−mk)∑i=2kPr⁡(Amk+1=i)Δi \begin{aligned} R_{\operatorname{ETC}(m)} (n) & = \mathbb E\left[\sum\limits_{i=1}^n \Delta_{A_i}\right] \\ & = \sum\limits_{i=1}^n \sum_{j=1}^k\Pr(A_i=j)\Delta_j \\ & = m\sum_{i=2}^k\Delta_i + (n-mk)\sum_{i=2}^k\Pr(A_{mk+1}=i)\Delta_i \end{aligned}

Moreover,

Pr⁡(Amk+1=i)≤Pr⁡(μ^i≥max⁡a∈A,a≠iμa)≤Pr⁡(μ^i≥μ1)=Pr⁡((μ^i−μ^1)−(μi−μ1)≥Δi)≤exp⁡(−mΔi24) \begin{aligned} \Pr(A_{mk+1}=i) & \le \Pr(\hat \mu_{i} \ge \max_{a\in\mathcal A, a\ne i}\mu_a) \\ & \le \Pr(\hat \mu_{i} \ge \mu_1) \\ & = \Pr((\hat\mu_{i}-\hat\mu_1) - (\mu_i-\mu_1)\ge \Delta_i) \\ & \le \exp\left(\frac{-m\Delta_i^2}{4}\right) \end{aligned}

The first inequality is strict when multiple arms tie, because the tie-breaking rule is random. The last inequality follows since X−YX-Y is 2\sqrt{2}-sub-Gaussian when XX and YY are 11-sub-Gaussian, and then we can apply the Hoeffding’s Inequality.

Hence, we have

RETC⁡(m)(n)≤m∑i=2kΔi+(n−mk)∑i=2kΔiexp⁡(−mΔi24) R_{\operatorname{ETC}(m)} (n) \le m\sum_{i=2}^k\Delta_i + (n-mk)\sum_{i=2}^k\Delta_i\exp\left(-\frac{m\Delta_i^2}{4}\right)

When k=2k=2 and writing Δ=Δ2\Delta = \Delta_2, we have

RETC⁡(m)(n)≤mΔ+(n−mk)Δexp⁡(−mΔ24)≤mΔ+nΔexp⁡(−mΔ24) R_{\operatorname{ETC}(m)} (n) \le m\Delta + (n-mk)\Delta\exp\left(-\frac{m\Delta^2}{4}\right)\le m\Delta + n\Delta\exp\left(-\frac{m\Delta^2}{4}\right)

Differentiating the RHS with respect to mm shows it is minimized at

m=max⁡(1,⌈4Δ2log⁡(nΔ24)⌉),m=\max\left(1,\left\lceil\frac{4}{\Delta^2}\log\left(\frac{n\Delta^2}{4}\right)\right\rceil\right),

which implies

RETC⁡(m)(n)≤min⁡(nΔ,Δ+4Δ(1+max⁡(0,log⁡(nΔ24)))) \boxed{ R_{\operatorname{ETC}(m)} (n) \le \min \left( n\Delta, \Delta + \frac{4}{\Delta} \left( 1 + \max \left( 0, \log \left( \frac{n\Delta^2}{4} \right) \right) \right) \right) }

Note that m≥1m \ge 1, and RETC⁡(m)(n)R_{\operatorname{ETC}(m)} (n) cannot exceed nΔn\Delta as discussed above. Informally, this bound says that, for fixed gap Δ\Delta, the regret of ETC grows only logarithmically with the horizon nn, but with a relatively large constant and the need to know (or tune around) Δ\Delta to choose mm.

We can plot how RETC⁡(n)R_{\operatorname{ETC}} (n) changes with Δ\Delta using a short Python snippet:

Python Code: ETC Regret Upper Bound
python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
import numpy as np
import matplotlib.pyplot as plt

n = 1000
eps = 1e-6
deltas = np.linspace(eps, 100.0, 1000)

term_linear = n * deltas
term_log = deltas + (4 / deltas) * (1 + np.maximum(0, np.log(n * deltas**2 / 4)))
bound = np.minimum(term_linear, term_log)

plt.figure(figsize=(6, 4))
plt.plot(deltas, bound, label=r"$R_{\mathrm{ETC}}(n)$ upper bound")
plt.xlabel(r"$\Delta$")
plt.ylabel(r"regret bound")
plt.title(f"ETC regret bound vs Δ (n={n})")
plt.grid(True, ls="--", alpha=0.5)
plt.legend()
plt.tight_layout()
plt.show()

The regret bound diverges as Δ→∞\Delta \to \infty. If we restrict to Δ≤1\Delta \le 1 (arms are 11-sub-Gaussian), the bound is maximized near Δ≈2en\Delta \approx \frac{2\sqrt{e}}{\sqrt{n}}, where RETC⁡(n)≈4neR_{\operatorname{ETC}} (n) \approx \frac{4\sqrt{n}}{\sqrt{e}} (from differentiating the RHS with respect to mm). For fixed Δ\Delta, the gap-dependent upper bound scales as O((log⁡n)/Δ)O((\log n)/\Delta), but unlike UCB it needs a good estimate of Δ\Delta (to choose mm) and carries larger constants.

Varaints of ETC

ETC is intuitive but too simple, which leads to the folloing disadvatages:

  1. It requires the prior of Δ\Delta to find the best mm for exploration, which are usually unknown in real scenerios.
  2. It is too rigid. It may continually commit to the wrong arms in the exploration phase.
  3. Theorectically, it is usually two times of the gap-dependent lower bound.
Proposition: Lower Bound of ETC
The lower bound of ETC is no less than two times of the gap-dependent lower bound.
Proof: Lower Bound of ETC

We only prove a special case with two arms a1a_1 and a2a_2 with Gaussian distribution σ1\sigma_1. Consider the gap-dependent lower bound:

Lgap-dependent(n)≥Δlog⁡nKL⁡(Pa1,Pa2) L_{\text{gap-dependent}} (n) \ge \frac{\Delta\log n}{\operatorname{KL}(P_{a_1}, P_{a_2})}

And

KL⁡(N(μ1,1),N(μ2,1))=Ex∼Pa1[log⁡(Pa1(x)Pa2(x))]=Ex∼Pa1[log⁡(12πexp⁡(−(x−μ1)22)12πexp⁡(−(x−μ2)22))]=(μ1−μ2)Ex∼Pa1[x−μ1+μ22]=(μ1−μ2)22=Δ22 \begin{aligned} \operatorname{KL}\left(\mathcal N(\mu_1, 1), \mathcal N(\mu_2, 1)\right) &= \mathbb E_{x\sim P_{a_1}}\left[\log\left(\frac{P_{a_1}(x)}{P_{a_2}(x)}\right)\right] \\ &=\mathbb E_{x\sim P_{a_1}}\left[\log\left(\frac{\frac{1}{\sqrt{2\pi}}\exp\left(-\frac{(x-\mu_1)^2}{2}\right)}{\frac{1}{\sqrt{2\pi}}\exp\left(-\frac{(x-\mu_2)^2}{2}\right)}\right)\right] \\ &=\left(\mu_1-\mu_2\right)\mathbb E_{x\sim P_{a_1}}\left[x-\frac{\mu_1+\mu_2}{2}\right] \\ & = \frac{\left(\mu_1-\mu_2\right)^2}{2} \\ & = \frac{\Delta^2}{2} \end{aligned}

Hence,

Lgap-dependent(n)=2Δlog⁡n L_{\text{gap-dependent}} (n) = \frac{2}{\Delta} \log n

But the The lower bound of ETC is

LETC=Ω(4Δlog⁡n) L_{\text{ETC}} = \Omega\left(\frac{4}{\Delta}\log n\right)

with a multiplicative constant of 22.

□\square

Hence, there are two common variants of ETC to address the above disadvantages:

Epoch Greedy ETC

Rather than committing to the arm with the highest estimated mean, Epoch Greedy ETC commits to the arm with the highest estimated mean in each epoch. alt text

ε\varepsilon-Greedy ETC

Toss a coin with probability ε\varepsilon to commit to the arm with the highest estimated mean, otherwise commit to a random arm. alt text

Upper Confidence Bound (UCB)

UCB is a classical algorithm for MAB problems. It follows the optimism‑in‑the‑face‑of‑uncertainty principle: arms with larger statistical uncertainty receive a positive bonus, so rarely sampled arms are explored more. ucb

Throughout this subsection we write RUCB(n)R_{\mathrm{UCB}}(n) for the expected pseudo-regret of the UCB algorithm at horizon nn.

Definition: Upper Confidence Bound Algorithm

Given the environment below

  • kk: number of arms
  • nn: horizon, n>kn > k
  • A={ai}i=1k\mathcal A = \{a_i\}_{i=1}^{k}

Let μ^a\hat \mu_a be the empirical mean of arm aa after Nt(a)N_t(a) pulls by round tt. The arm chosen at round tt is

At=arg max⁡a∈A(μ^a+Bt(a)),Bt(a)=αlog⁡tNt(a), A_t = \argmax_{a\in\mathcal A} \bigl(\hat \mu_a + B_t(a)\bigr), \qquad B_t(a) = \sqrt{\frac{\alpha\log t}{N_t(a)}},

where α>0\alpha>0 is a hyperparameter (commonly α=2\alpha=2).

The bonus Bt(a)B_t(a) shrinks as Nt(a)N_t(a) grows and increases slowly with tt, encouraging exploration of under‑sampled arms.

The form of Bt(a)B_t(a) comes directly from Hoeffding’s Inequality.

Derivation of Bt(a)B_t(a)

Let arm aa have σ\sigma‑sub-Gaussian rewards. Hoeffding gives

Pr⁡(μ^a−μa≥ε)≤exp⁡ ⁣(−Nt(a)ε22σ2). \Pr\bigl(\hat \mu_a - \mu_a \ge \varepsilon\bigr) \le \exp\!\left(-\frac{N_t(a)\varepsilon^2}{2\sigma^2}\right).

To make this error probability decay at most on the order of t−βt^{-\beta} for some β>0\beta>0, it suffices that

exp⁡ ⁣(−Nt(a)ε22σ2)≤t−β. \exp\!\left(-\frac{N_t(a)\varepsilon^2}{2\sigma^2}\right) \le t^{-\beta}.

Solving for ε\varepsilon suggests choosing

ε=αlog⁡tNt(a),α=2σ2β. \varepsilon = \sqrt{\frac{\alpha\log t}{N_t(a)}}, \qquad \alpha = 2\sigma^2\beta.

Next we sketch the regret of UCB. Assume all arms are 12\tfrac{1}{2}‑sub-Gaussian, and β=4\beta = 4, hence α=2\alpha = 2. Order the arms so that μ1≥μ2≥⋯≥μk\mu_1 \ge \mu_2 \ge \cdots \ge \mu_k and define the gaps Δi=μ1−μi\Delta_i = \mu_1 - \mu_i for i≥2i\ge2.

For each round tt, define the good event

Gt={∀i∈[1,k],  ∣μ^i−μi∣≤Bt(i)}. G_t = \left\{\forall i\in[1,k],\; \bigl|\hat \mu_i - \mu_i\bigr| \le B_t(i)\right\}.

By Hoeffding’s inequality and a union bound over arms, one can choose the constant in Bt(i)B_t(i) (equivalently, in β\beta) so that

Pr⁡(¬Gt)=O ⁣(1t4). \Pr(\neg G_t) = O\!\left(\frac{1}{t^4}\right).

We decompose the regret horizon‑wise:

RUCB⁡(n)=∑t=1nE[ΔAt]=∑t=1nE[ΔAt1Gt]+∑t=1nE[ΔAt1¬Gt]. R_{\operatorname{UCB}}(n) = \sum_{t=1}^n \mathbb E[\Delta_{A_t}] = \sum_{t=1}^n \mathbb E[\Delta_{A_t}\mathbf 1_{G_t}] + \sum_{t=1}^n \mathbb E[\Delta_{A_t}\mathbf 1_{\neg G_t}].

Since the instantaneous regret is at most Δmax⁡≔max⁡i≥2Δi\Delta_{\max}\coloneqq\max_{i\ge2}\Delta_i, the second sum is bounded by

∑t=1nE[ΔAt1¬Gt]≤Δmax⁡∑t=1nPr⁡(¬Gt)≤Δmax⁡∑t=1∞O ⁣(1t4)=O(1), \sum_{t=1}^n \mathbb E[\Delta_{A_t}\mathbf 1_{\neg G_t}] \le \Delta_{\max}\sum_{t=1}^n \Pr(\neg G_t) \le \Delta_{\max}\sum_{t=1}^\infty O\!\left(\frac{1}{t^4}\right) = O(1),

so the contribution from the “bad” events ¬Gt\neg G_t is a constant independent of nn.

On the good events GtG_t, regret depends on how often suboptimal arms are pulled. Let Nn(ai)N_n(a_i) be the number of pulls of arm aia_i up to round nn. Expanding ΔAt\Delta_{A_t} over arms gives

ΔAt=∑i=2kΔi 1{At=ai}, \Delta_{A_t} = \sum_{i=2}^k \Delta_i\,\mathbf 1\{A_t = a_i\},

so

RUCB⁡(n)=∑t=1nE[ΔAt1Gt]+O(1)=∑t=1n∑i=2kΔi E[1{At=ai}1Gt]+O(1)=∑i=2kΔi E[∑t=1n1{At=ai}1Gt]+O(1)≤∑i=2kΔi E[∑t=1n1{At=ai}]+O(1)=∑i=2kΔi E[Nn(ai)]+O(1). R_{\operatorname{UCB}}(n) = \sum_{t=1}^n \mathbb E[\Delta_{A_t}\mathbf 1_{G_t}] + O(1) \\ = \sum_{t=1}^n \sum_{i=2}^k \Delta_i\,\mathbb E\bigl[\mathbf 1\{A_t = a_i\}\mathbf 1_{G_t}\bigr] + O(1) \\ = \sum_{i=2}^k \Delta_i\,\mathbb E\Bigl[\sum_{t=1}^n \mathbf 1\{A_t = a_i\}\mathbf 1_{G_t}\Bigr] + O(1) \\ \le \sum_{i=2}^k \Delta_i\,\mathbb E\Bigl[\sum_{t=1}^n \mathbf 1\{A_t = a_i\}\Bigr] + O(1) = \sum_{i=2}^k \Delta_i\,\mathbb E\bigl[N_n(a_i)\bigr] + O(1).

Whenever a suboptimal arm aia_i is chosen at round tt and GtG_t holds, the selection rule implies

μ^ai+Bt(ai)≥μ^a1+Bt(a1), \hat\mu_{a_i} + B_t(a_i) \ge \hat\mu_{a_1} + B_t(a_1),

which together with ∣μ^ai−μi∣≤Bt(ai)\bigl|\hat\mu_{a_i} - \mu_i\bigr|\le B_t(a_i) and ∣μ^a1−μ1∣≤Bt(a1)\bigl|\hat\mu_{a_1} - \mu_1\bigr|\le B_t(a_1) yields

μi+2Bt(ai)≥μ1⟹Bt(ai)≥Δi2. \mu_i + 2B_t(a_i) \ge \mu_1 \quad\Longrightarrow\quad B_t(a_i) \ge \frac{\Delta_i}{2}.

Recalling that with α=2\alpha=2 we have Bt(ai)=2log⁡tNt(ai)B_t(a_i) = \sqrt{\tfrac{2\log t}{N_t(a_i)}}, this implies

2log⁡tNt(ai)≥Δi2⟹Nt(ai)≤8log⁡tΔi2, \sqrt{\frac{2\log t}{N_t(a_i)}} \ge \frac{\Delta_i}{2} \quad\Longrightarrow\quad N_t(a_i) \le \frac{8\log t}{\Delta_i^2},

and hence in particular

Nn(ai)≤8log⁡nΔi2. N_n(a_i) \le \frac{8\log n}{\Delta_i^2}.

Plugging this back into the regret expression and combining with the constant contribution from bad events, we obtain

RUCB⁡(n)=O ⁣(∑i=2klog⁡nΔi). R_{\operatorname{UCB}}(n) = O\!\left(\sum_{i=2}^k \frac{\log n}{\Delta_i}\right).

In particular, if we let Δ=min⁡i≥2Δi\Delta = \min_{i\ge2}\Delta_i and denote the UCB regret at horizon nn by RUCB(n)R_{\mathrm{UCB}}(n), then

RUCB(n)=O ⁣(log⁡nΔ). R_{\mathrm{UCB}}(n) = O\!\left(\frac{\log n}{\Delta}\right).

Putting this together with the ETC analysis above, both RETC(n)R_{\mathrm{ETC}}(n) and RUCB(n)R_{\mathrm{UCB}}(n) achieve a gap‑dependent logarithmic rate O((log⁡n)/Δ)O((\log n)/\Delta), but ETC needs a well‑tuned exploration length mm (which in turn depends on the unknown gap), whereas UCB attains the same order of regret without any prior knowledge of Δ\Delta by adapting its exploration bonus online.


  1. Many expositions (e.g., Introduction to Multi-Armed Bandits, pp. 5–6) present regret directly under expectation and sometimes blur the distinction between pathwise and expected quantities. The split into realized, random, and expected pseudo‑regret avoids that ambiguity. ↩︎

  2. This section mainly refers to the ITCS course taught by Prof. Zhengfeng Ji. ↩︎

Last updated on 2026-09-07