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.
Let’s abstract the gambling game to a formal problem definition:
Definition: Stochastic Multi-Armed Bandit(MAB) Problem
Let A={a1,a2,…,aK} be the set of arms. Pulling arm ak at round t yields a reward Rt,k∼Dk, where each Dk is an unknown distribution with mean μk. Over a finite horizon T, a policy chooses arms (ai1,…,aiT) and observes rewards (R1,i1,…,RT,iT). The objective is to maximize the expected cumulative reward Eπ[∑t=1TRt,it].
where the Ri 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, and we write μ∗=1≤k≤Kmaxμk for the optimal mean.
Definition: Realized Pseudo-Regret
Fix a policy π and a sample path ω=(ai1,ai2,…,aiT)∈Ω. Let At:Ω→A denote the random arm chosen at round t, and write At(ω)=ait for its realization along ω. The realized pseudo-regret at horizon T is
Rπ(T,ω)=t=1∑T(μ∗−μ(At(ω)))=Tμ∗−t=1∑Tμit.
Definition: Random Pseudo-Regret
Under policy π, the (trajectory-dependent) random pseudo-regret is the random variable
Rπ(T)=t=1∑T(μ∗−μ(At))=Tμ∗−t=1∑Tμ(At),
It represents the regret as a random variable before taking expectation.
Definition: Expected Pseudo-Regret
The expected pseudo-regret of policy π is
Rπ(T)=Eπ[Rπ(T)]=∫ΩRπ(T,ω)dPπ(ω),
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:
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∗∈argmaxkμk and let rt(a) denote the realized reward at round t if arm a were pulled. Then the realized regret along ω is
Rπreal(T,ω)=t=1∑T(rt(a∗)−rt(At(ω))).
Taking expectation over the reward noise (with rt(a)∼Da) recovers the pseudo‑regret:
E[Rπreal(T,ω)∣A1(ω),…,AT(ω)]=Rπ(T,ω).
In analysis we usually work with pseudo‑regret, and when context is clear we simply say “regret”.
Why is At 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:Ω→A is a random variable.
Lower Bounds
For convenience, we only talk about the realized regret under a fixed trajectory ω and a fixed policy π and simplify the Rπ(T,ω) as 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=1∑T(μ∗−μ(At(ω)))≤t=1∑T(μ∗−μ′)=TΔ=Ω(T)
where μ′=1≤k≤Kminμk,Δ=μ∗−μ′.
Hence, a wise algorithm should be sub-linear, i.e. o(T).
Two common lower bounds are:
Gap-independent:
Ω(TK)
Gap-dependent:
Ωai=a∗∑(KL(Pai,Pa∗)Δi)logT
where K is the number of arms; Δi is the gap between the mean of a∗ and ai; 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 Ω(logT) which is less than Ω(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.
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; 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)≤aE(X)
where X is a non-negative random variable.
Proof: Markov’s Inequality
Consider the indicator function for X≥a:
1{X≥a}={10X≥aX<a
By the definition of expectation, E[1{X≥a}]=Pr(X≥a).
If X<a, then 1{X≥a}=0 and X≥0=a1{X≥a}; if X≥a, then 1{X≥a}=1 and X≥a=a1{X≥a}. Thus X≥a1{X≥a} always holds.
Taking expectations on both sides yields
E(X)≥aE[1{X≥a}]=aPr(X≥a),
i.e.
Pr(X≥a)≤aE(X).
□
Chebyshev’s Inequality
Proposition: Chebyshev’s Inequality
Pr(∣X−μ∣≥kσ)≤k21,for any k>0,
where μ is the expectation of X, and σ is the standard deviation of X.
where the last equality uses Var(X)=E[(X−μ)2]=σ2. □
Chernoff Bound
The Chernoff bound is a technique to estimate tail bounds quantitatively, i.e., Pr(X≥a) or Pr(X≤a). We can summarize it in three steps:
Chernoff Bound Trick Steps
For t∈R, apply the map x↦etx to obtain Pr(etX≥eta). When t>0 this bounds the upper tail Pr(X≥a); when t<0 it bounds the lower tail Pr(X≤a). This ensures the random variable etX is non‑negative so Markov’s inequality applies.
Choose t to make the right‑hand side as small as possible (optimize over t): Pr(X≥a)≤t>0infe−taMX(t),Pr(X≤a)≤t<0infe−taMX(t),
where MX(t)=E[etX] is the moment generating function (MGF) of X.
As an illustration, consider Bernoulli trials and apply the Chernoff bound.
Suppose we have n i.i.d. Bernoulli trials Xi with success probability p. Let X=∑iXi; then μ=E[X]=np. Suppose λ>1.
Consider the function f(t)=nlog(pet+1−p)−tλnp. Taking the derivative and setting it to 0, we have
f′(t)=pet+1−pnpet−λnp=0
i.e.,
t∗=logλ+log(1−p)−log(1−λp).
It is easy to verify that f(t) attains its minimum at t∗. Substituting t∗ into f(t), we have
f(t∗)=−n((1−λp)log1−p1−λp+λplogλ)=−nDKL(λp∥p),
where DKL(q∥p)=qlogpq+(1−q)log1−p1−q is the Kullback–Leibler divergence between Bernoulli parameters.
t∗>0 since λ>1. Hence, we have
Pr(X≥λμ)≤exp(−nDKL(λp∥p)).
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 with Xi∈[ai,bi]. Let X=∑iXi and μ=E[X]. Then
Pr(X−μ≥ε)≤exp(−∑i=1n(bi−ai)22ε2)
or
Pr(X−μ≤−ε)≤exp(−∑i=1n(bi−ai)22ε2)
It’s easy to find out the Hoeffding’s inequality is a special case of Chernoff Bound.
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:
k: number of arms
n: horizon, n>k
A={ai}i=1k
The arm chosen at round t is:
At={(tmodk)+1argmaxa∈Aμ^at≤mkt>mk
where m<⌊kn⌋ is the number of times each arm is pulled and μ^a=m1∑i=1mra,i, with ra,i the reward of arm a on its i-th pull. Tie-breaking of argmax is usually random.
Consider the special case where all arms are 1-sub-Gaussian; this helps build intuition for the regret. For brevity, we denote the expected pseudo-regret of ETC at horizon n by RETC(n).
W.l.o.g., assume ∀i<j,μi≥μj, and define Δi=μ1−μi.
The first inequality is strict when multiple arms tie, because the tie-breaking rule is random. The last inequality follows since X−Y is 2-sub-Gaussian when X and Y are 1-sub-Gaussian, and then we can apply the Hoeffding’s Inequality.
Differentiating the RHS with respect to m shows it is minimized at
m=max(1,⌈Δ24log(4nΔ2)⌉),
which implies
RETC(m)(n)≤min(nΔ,Δ+Δ4(1+max(0,log(4nΔ2))))
Note that m≥1, and RETC(m)(n) cannot exceed nΔ as discussed above. Informally, this bound says that, for fixed gap Δ, the regret of ETC grows only logarithmically with the horizon n, but with a relatively large constant and the need to know (or tune around) Δ to choose m.
We can plot how RETC(n) changes with Δ using a short Python snippet:
importnumpyasnpimportmatplotlib.pyplotaspltn=1000eps=1e-6deltas=np.linspace(eps,100.0,1000)term_linear=n*deltasterm_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 Δ→∞. If we restrict to Δ≤1 (arms are 1-sub-Gaussian), the bound is maximized near Δ≈n2e, where RETC(n)≈e4n (from differentiating the RHS with respect to m). For fixed Δ, the gap-dependent upper bound scales as O((logn)/Δ), but unlike UCB it needs a good estimate of Δ (to choose m) and carries larger constants.
Varaints of ETC
ETC is intuitive but too simple, which leads to the folloing disadvatages:
It requires the prior of Δ to find the best m for exploration, which are usually unknown in real scenerios.
It is too rigid. It may continually commit to the wrong arms in the exploration phase.
Theorectically, it is usually two times of the gap-dependent lower bound.
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.
ε-Greedy ETC
Toss a coin with probability ε to commit to the arm with the highest estimated mean, otherwise commit to a random arm.
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.
Throughout this subsection we write RUCB(n) for the expected pseudo-regret of the UCB algorithm at horizon n.
Definition: Upper Confidence Bound Algorithm
Given the environment below
k: number of arms
n: horizon, n>k
A={ai}i=1k
Let μ^a be the empirical mean of arm a after Nt(a) pulls by round t. The arm chosen at round t is
Let arm a have σ‑sub-Gaussian rewards. Hoeffding gives
Pr(μ^a−μa≥ε)≤exp(−2σ2Nt(a)ε2).
To make this error probability decay at most on the order of t−β for some β>0, it suffices that
exp(−2σ2Nt(a)ε2)≤t−β.
Solving for ε suggests choosing
ε=Nt(a)αlogt,α=2σ2β.
Next we sketch the regret of UCB. Assume all arms are 21‑sub-Gaussian, and β=4, hence α=2. Order the arms so that μ1≥μ2≥⋯≥μk and define the gaps Δi=μ1−μi for i≥2.
For each round t, define the good event
Gt={∀i∈[1,k],μ^i−μi≤Bt(i)}.
By Hoeffding’s inequality and a union bound over arms, one can choose the constant in Bt(i) (equivalently, in β) so that
so the contribution from the “bad” events ¬Gt is a constant independent of n.
On the good events Gt, regret depends on how often suboptimal arms are pulled. Let Nn(ai) be the number of pulls of arm ai up to round n. Expanding ΔAt over arms gives
Whenever a suboptimal arm ai is chosen at round t and Gt holds, the selection rule implies
μ^ai+Bt(ai)≥μ^a1+Bt(a1),
which together with μ^ai−μi≤Bt(ai) and μ^a1−μ1≤Bt(a1) yields
μi+2Bt(ai)≥μ1⟹Bt(ai)≥2Δi.
Recalling that with α=2 we have Bt(ai)=Nt(ai)2logt, this implies
Nt(ai)2logt≥2Δi⟹Nt(ai)≤Δi28logt,
and hence in particular
Nn(ai)≤Δi28logn.
Plugging this back into the regret expression and combining with the constant contribution from bad events, we obtain
RUCB(n)=O(i=2∑kΔilogn).
In particular, if we let Δ=mini≥2Δi and denote the UCB regret at horizon n by RUCB(n), then
RUCB(n)=O(Δlogn).
Putting this together with the ETC analysis above, both RETC(n) and RUCB(n) achieve a gap‑dependent logarithmic rate O((logn)/Δ), but ETC needs a well‑tuned exploration length m (which in turn depends on the unknown gap), whereas UCB attains the same order of regret without any prior knowledge of Δ by adapting its exploration bonus online.
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. ↩︎
This section mainly refers to the ITCS course taught by Prof. Zhengfeng Ji. ↩︎
Last updated on 2026-09-07
Loading comments…
Comments failed to load. Disqus may be blocked on your network.
Loading comments…
Comments failed to load. Disqus may be blocked on your network.