Concentration Inequalities and Randomized Algorithms
Chihao Zhang · Fall 2026
Randomness can be super powerful in designing algorithms. It can help an algorithm run faster and avoid worst-case inputs. Concentration inequalities are a key tool to both analyze and design randomized algorithms. We develop basic concentration tools and study two concrete examples in this section. Morris’s algorithm counts a long stream using a small random counter. Explore-Then-Commit uses samples to decide which action to take in a multi-armed bandit problem. The same concentration tools control the accuracy of the counter and the reliability of the decision.
How to read these notes. Part I contains the course content. Part II develops additional reading on martingales, sub-Gaussian and sub-exponential variables, and UCB. Part III introduces four further topics through their background, main guarantees, and references. These are established results to study and explain; their proofs are not included in Part III.
We assume basic probability, expectation, variance, and independence. All logarithms are natural unless the base is displayed. An assertion about a random variable’s range is understood to hold almost surely.
I. Course Content
1.1 Markov and Chebyshev inequalities
We first recall Markov’s inequality and Chebyshev’s inequality we met in the probability theory course.
Proposition 1 (Markov’s inequality) For any non-negative random variable X with finite expectation and for any a>0, P(X≥a)≤aEX.
Proof
Since X is non-negative, we have EX≥a⋅P(X≥a)+0⋅P(X<a). This is equivalent to P(X≥a)≤aEX.
Proposition 2 (Chebyshev’s inequality) For any random variable X with finite variance and for any a>0, it holds that P(∣X−EX∣≥a)≤a2Var(X).
Proof
Let Y=∣X−EX∣, then clearly Y≥0. Therefore P(∣X−EX∣≥a)=P(Y≥a)=P(Y2≥a2)≤a2E[Y2]=a2E[(X−EX)2]=a2Var(X).
In order to motivate the study of concentration inequalities, let’s first look at the streaming model.
1.2 The streaming model
Suppose we have a router with limited memory, but need to solve some computational tasks with large input data such as monitoring the IDs of devices visiting it. The following questions are usually asked.
How many numbers are in a given data stream?
How many distinct numbers?
What is the most frequent number?
In order to study these problems systematically, we need to formally define the streaming model. In the streaming model, the input is a sequence σ=⟨a1,a2,…,am⟩ where each ai∈[n]. We should notice that the data arrive one by one as suggested by the word “streaming” in the name. We now focus on the basic problem: How many numbers are in the stream (what is m)?
Clearly we can maintain a counter k, and whenever a number ai arrives, increase k by one. To represent every possible count from 0 to m, we need ⌈log2(m+1)⌉ bits of memory.
Can we design a more clever algorithm with only o(logm) memory? It turns out that computing the exact answer is impossible with fewer than ⌈log2(m+1)⌉ bits. The reason is as follows: suppose an algorithm uses fewer bits, so it has fewer than m+1 memory states. Denote by M(i) the memory state of the algorithm after an input σ of length i. Then there exist distinct i,j∈{0,1,…,m} such that M(i)=M(j), and the algorithm cannot output the correct length for both inputs.
Even though we cannot get a better algorithm for the exact answer, it is possible to save a lot of memory if approximation is allowed. That is, for every ε>0, the algorithm computes a number m such that 1−ε≤mm≤1+ε with high probability.
Morris’s algorithm
Morris’s algorithm is presented as follows.
Morris’s Algorithm
Input: An instance σ=⟨a1,a2,…,am⟩ where each ai∈[n].
Output: An estimate of the length m of the sequence σ.
X←0;
On each input: X←X+1 with probability 2−X;
Return 2X−1.
This is a randomized algorithm with approximately O(loglogm) bits of memory. We first look at the expectation of its output.
Theorem 1 (Morris’s estimator is unbiased) The output of Morris’s algorithm m satisfies Em=m.
Proof. We prove it by induction on m. Since X=1 when m=1, we have Em=1. Assume it is true for smaller m, and let Xi denote the value of X after processing the ith input. We have E[2Xm∣Xm−1=i]=(1−2−i)2i+2−i2i+1=2i+1. Therefore, Em=E[2Xm]−1=E[2Xm−1+1]−1=E[2Xm−1]=m, where the last equation holds due to the induction hypothesis.
It is now clear that Morris’s algorithm is an unbiased estimator for m. However, for a practical randomized algorithm, we further require its output to concentrate around the expectation. That is, we want to establish a concentration inequality of the form P(∣m−m∣≥εm)≤δ for ε,delta>0. It is natural to see that for fixed ε, the smaller δ is, the better the algorithm is.
To use Chebyshev’s inequality to analyze the concentration of Morris’s algorithm, we have to compute the variance of m.
Lemma 1 (Second moment of the Morris counter)E[(2Xm)2]=23m2+23m+1.
Proof
We can prove the claim using an induction argument similar to our proof for the expectation. When m=1, E[(2Xm)2]=4. We assume it is true for smaller m and use the same notation Xi. Conditioning on Xm−1 gives E[22Xm∣Xm−1=i]=(1−2−i)22i+2−i22(i+1)=22i+3⋅2i. Hence E[22Xm]=E[22Xm−1]+3E[2Xm−1]=23(m−1)2+23(m−1)+1+3m=23m2+23m+1.
With the above lemma, we can compute the variance as follows: Var(m)=E[(2Xm−1)2]−m2=2m(m−1)≤2m2. Applying Chebyshev’s inequality, we obtain that for every ε>0, P(∣m−m∣≥εm)≤2ε21. However, we observe that as ε becomes smaller, the above bound is not useful. Thus, it is necessary to improve the concentration of the algorithm. We now introduce two common tricks to achieve this.
The averaging trick
Chebyshev’s inequality tells us that we can improve the concentration by reducing the variance. Let’s first review some properties of variances. Let X be a random variable. We have Var(aX)=a2Var(X) for any constant a. For any two independent random variables X and Y, we have Var(X+Y)=Var(X)+Var(Y).
We can design a new algorithm by independently running Morris’s algorithm t times in parallel. Denote the corresponding outputs by m1,…,mt. The final output is m∗:=t∑i=1tmi. By the above two properties, we have Var(m∗)=Var(m1)/t. We can apply Chebyshev’s inequality to m∗ and obtain P(∣m∗−m∣≥εm)≤2tε21. For t≥1/(2ε2δ), we have P(∣m∗−m∣≥εm)≤δ.
The new algorithm uses approximately O(ε2δloglogm) bits of memory. It shows a trade-off between the accuracy of the randomized algorithm and the consumption of memory space. We can further improve the dependence on δ using the Chernoff bound below.
1.3 Chernoff bounds and success amplification
Like Chebyshev’s inequality, if we choose f(x)=eαx for α>0 and apply Markov’s inequality to f(X), the bound amounts to bounding E[eαX], which is the moment generating function of X. In case E[eαX] can be well bounded, we obtain sharp concentration bounds.
Theorem 2 (Chernoff bound) Let X1,…,Xn be independent random variables such that Xi∼Ber(pi) for each i=1,2,…,n. Let X=∑i=1nXi and denote μ:=EX=∑i=1npi. For δ>0, we have P(X≥(1+δ)μ)≤((1+δ)1+δeδ)μ. If 0<δ<1, then we have P(X≤(1−δ)μ)≤((1−δ)1−δe−δ)μ.
Proof. We only prove the upper tail bound and the proof of the lower tail bound is similar. For every α>0, we have P(X≥(1+δ)μ)=P(eαX≥eα(1+δ)μ)≤eα(1+δ)μE[eαX]. Therefore, we need to estimate the moment generating function E[eαX]. Since X=∑i=1nXi is the sum of independent Bernoulli variables, we have E[eαX]=E[i=1∏neαXi]=i=1∏nE[eαXi]. Since Xi∼Ber(pi), we can compute E[eαXi] directly: E[eαXi]=pieα+(1−pi)=1+(eα−1)pi≤exp((eα−1)pi). Therefore, E[eαX]≤i=1∏nexp((eα−1)pi)=exp((eα−1)μ). Consequently, P(X≥(1+δ)μ)≤exp(μ(eα−1−α(1+δ))). Note that the above holds for any α>0. Therefore, we can choose α so as to minimize the exponent. Its derivative is eα−1−δ, which gives α=log(1+δ). Substituting this value gives P(X≥(1+δ)μ)≤((1+δ)1+δeδ)μ.
The following form of the Chernoff bound is more convenient to use (but weaker).
Corollary 1 (Corollary) For any 0<δ<1, P(X≥(1+δ)μ)P(X≤(1−δ)μ)≤exp(−3δ2μ),≤exp(−2δ2μ).
Proof
We only prove the upper tail. It suffices to verify that for 0<δ<1, (1+δ)1+δeδ≤exp(−3δ2). Taking logarithms, this is equivalent to δ−(1+δ)log(1+δ)≤−3δ2. Let f(δ)=δ−(1+δ)log(1+δ)+δ2/3. Then f′(δ)=−log(1+δ)+32δ,f′′(δ)=−1+δ1+32. For 0<δ<1/2, f′′(δ)<0, and for 1/2<δ<1, f′′(δ)>0. Therefore, f′ first decreases and then increases on [0,1]. Also f′(0)=0 and f′(1)<0, so f′(δ)≤0 on [0,1]. Hence f(δ)≤f(0)=0.
The median trick
We can further boost the performance of Morris’s algorithm using the median trick. We choose t=⌈3/(2ε2)⌉ in the algorithm introduced in the averaging trick and independently run it s times in parallel. Denote the outputs by m1∗,m2∗,…,ms∗. It holds that for every i=1,…,s, P(∣mi∗−m∣≥εm)≤31. At last, we output the median m∗∗ of m1∗,…,ms∗.
Then we can apply the Chernoff bound to analyze the result obtained by the median trick. For every i=1,…,s, let Yi be the indicator of the good event ∣mi∗−m∣<εm. Then Y:=∑i=1sYi satisfies EY≥2s/3. If the median m∗∗ is bad, then at least half of the mi∗ are bad. Equivalently, Y≤s/2. By the Chernoff bound, P(∣Y−EY∣≥6s)≤2exp(−72s). Therefore, for t=O(1/ε2) and s=O(log(1/δ)), we have P(∣m∗∗−m∣≥εm)≤δ. This new algorithm uses O(ε21logδ1⋅loglogm) bits of memory.
1.4 Hoeffding’s inequality
One annoying restriction of the Chernoff bound is that each Xi needs to be a Bernoulli random variable. Hoeffding’s inequality generalizes the Chernoff bound by allowing Xi to follow any distribution, provided its value is almost surely bounded.
Theorem 3 (Hoeffding’s inequality) Let X1,…,Xn be independent random variables where each Xi∈[ai,bi] for certain ai≤bi almost surely. Assume EXi=pi for every 1≤i≤n. Let X=∑i=1nXi and μ:=EX=∑i=1npi. Then P(∣X−μ∣≥t)≤2exp(−∑i=1n(bi−ai)22t2) for all t>0.
We learnt from the proof of the Chernoff bound that the key to establishing concentration inequalities of this form is to obtain a nice upper bound on the moment generating function. Therefore, the following Hoeffding lemma will be the main technical ingredient to prove the inequality.
Lemma 2 (Hoeffding’s lemma) Let X be a random variable with EX=0 and X∈[a,b]. Then EeλX≤exp(8λ2(b−a)2)for all λ∈R.
Proof. Let ψ(λ)=logE[eλX]. We first compute its derivatives: ψ′(λ)=EeλXE[XeλX], and ψ′′(λ)=EeλXE[X2eλX]−E[eλX]2E[XeλX]2. When λ=0, using the condition EX=0, we have ψ(0)=ψ′(0)=0. Let P be the distribution of X. We can interpret ψ′′ as the variance of a tilted random variable: ψ′′(λ)=VarQλ(X), where dPdQλ(x)=E[eλX]eλx. Since X is supported on [a,b], for every λ, VarQλ(X)≤EQλ[(X−2a+b)2]≤4(b−a)2. Therefore, by Taylor’s formula, ψ(λ)=λ2∫01(1−s)ψ′′(sλ)ds and hence ψ(λ)≤λ2(b−a)2/8.
Armed with Hoeffding’s lemma, it is routine to prove Hoeffding’s inequality.
Proof of Hoeffding’s inequality
First note that we can assume EXi=0 and therefore μ=0; if not, replace Xi by Xi−EXi. Put V=∑i=1n(bi−ai)2. By symmetry, we only need to prove the upper tail. Since P(X≥t)=P(eλX≥eλt)≤eλtE[eλX] and E[eλX]=E[eλ∑i=1nXi]=i=1∏nE[eλXi], applying Hoeffding’s lemma for each factor yields E[eλXi]≤exp(8λ2(bi−ai)2). Let λ=4t/V. We have P(X≥t)≤exp(−λt+8λ2V)=exp(−V2t2).
1.5 Multi-armed bandits: Explore-Then-Commit
Suppose there is a k-arm bandit, and the reward of each arm follows some distribution fi supported on [0,1] with mean μi; rewards are independent across arms and rounds. We assume without loss of generality that μ1≥μ2≥⋯≥μk. Now suppose you can pull the bandit for T rounds and the goal is to obtain maximum reward in expectation. If we know μ1,…,μk, the optimal strategy is to pull arm 1 for T times, and the expected reward is Tμ1. However, in case we do not know the distributions, we have to design some strategy to explore the bandit first.
Denote by at the arm pulled in round t, and thus the reward in the tth round satisfies Xt∼fat. The regret of a strategy is defined as the gap between Tμ1 and the expected rewards of the strategy in T rounds, namely the regret of not always choosing the first arm: R(T):=Tμ1−E[t=1∑TXt]≥0.
For every i∈[k], denote Δi:=μ1−μi≥0 as the gap between the reward of the ith arm and the optimal arm. The naive strategy that pulls each arm equally often is bad. When k divides T, its regret is R(T)=k∑i=1kΔiT, which is linear in T. We consider a strategy/algorithm good if limT→∞R(T)/T=0, or equivalently R(T)=o(T).
Proposition 3 For every t∈[T], let ni(t):=s=1∑t1{as=i} denote the number of times arm i is pulled in the first t rounds. Then R(T)=i=2∑kΔiE[ni(T)].
Proof
By conditioning on the chosen arm in each round, R(T)=Tμ1−E[t=1∑TXt]=Tμ1−t=1∑TE[μat]=t=1∑Ti=1∑kΔiE[1{at=i}]=i=1∑kΔiE[t=1∑T1{at=i}]=i=1∑kΔiE[ni(T)]. Since Δ1=0, this equals the stated sum.
We also write Ri(T):=ΔiE[ni(T)] for every i∈[k], and then R(T)=∑i=1kRi(T).
The algorithm and the trade-off
To get small regret, our strategy should identify the best arm as soon as possible. The most straightforward way to find the best arm is to try each arm a few times and pick the one with the best empirical reward. The Explore-Then-Commit algorithm implements this idea: pull every arm i for L times (so kL times in total for exploration), and calculate μi (the average reward gained in those L times). After this, always pull an arm J with the greatest μi. We assume kL≤T and use any fixed rule to break ties. We can write its regret as
R(T)=Li=1∑kΔi+(T−kL)E[ΔJ]. Moreover, E[ΔJ]=i=2∑kΔiP(J=i). When i=1, P(J=i)≤P(μi≥μ1).
We bound the above probability by concentration inequalities. To this end, let Xj be the jth reward from fi, and let Yj be the jth reward from f1. Let Zj=Xj−Yj∈[−1,1]; then EZj=−Δi≤0. Let Z=∑j=1LZj; then EZ=−LΔi. By Hoeffding’s inequality, P(μi≥μ1)=P(Z≥0)=P(Z−EZ≥LΔi)≤exp(−∑j=1L222(LΔi)2)=exp(−2LΔi2). Therefore, R(T)≤Li=1∑kΔi+Ti=2∑kΔie−LΔi2/2≤i=1∑k(L+TΔie−LΔi2/2).
A bound without knowing the gaps
To further upper bound R(T), define g(L,Δi):=L+TΔiexp(−2LΔi2). We would like to determine L minimizing the upper bound of R(T) among all possible Δi, i.e., minLmaxΔiR(T). First we calculate maxΔig(L,Δi): ∂Δi∂g(L,Δi)=T(1−LΔi2)exp(−2LΔi2). We have ∂g/∂Δi>0 when 0≤Δi<1/L, and ∂g/∂Δi<0 when 1≥Δi>1/L. Thus, for all L>1, g(L,Δi)≤g(L,L1)=L+LTe−1/2.
Finally, assuming kL≤T and setting L=Θ(T2/3), we have R(T)≤i=1∑k(L+LTe−1/2)=O(kT2/3).
The Explore-Then-Commit algorithm enjoys sublinear regret for fixed k, which is good, but still suboptimal. The main disadvantage is that it treats all arms equally in the exploration step and pulls each of them for a fixed L times regardless of the rewards already obtained.
II. Reading Contents
The classroom arguments leave two natural questions. Can we obtain concentration when observations are dependent, or when variables are not bounded? And can we use concentration to decide how many samples to collect? The following sections develop these questions without changing the basic exponential-moment strategy.
2.1 Concentration with martingales
Our concentration proofs for sums have used mutual independence to factor an MGF. When new observations depend on the past, factorization is no longer available. Conditional expectation gives a replacement: we bound the next factor after fixing everything observed so far, and then work backward.
A fair game and its information
Imagine a fair game in which the size of the next bet may depend on previous wins and losses. The increments need not be independent. What matters is that their conditional expected value is zero.
Definition 1 (Filtrations and martingales) A filtration(Ft)t≥0 is an increasing sequence of σ-algebras representing the information available over time. An integrable process (Zt) is a martingale if Zt is Ft-measurable and, for every t≥1, E[Zt∣Ft−1]=Zt−1. Equivalently, the increments Dt=Zt−Zt−1 have conditional mean zero.
For example, if X1,X2,… are independent and integrable, then Zt=∑i=1t(Xi−EXi) is a martingale with Z0=0. We have also already met a dependent example: for Morris’s counter, 2Xt−1−t is a martingale, by the conditional expectation calculation in Part I. Its increments are not uniformly small, so it does not directly give a useful bounded-increment estimate.
Revealing a function one coordinate at a time
Let W=f(X1,…,Xn) be integrable. Reveal the inputs successively and keep track of the current prediction of W: Zk=E[W∣X1,…,Xk],0≤k≤n. Here Z0=EW and Zn=W. The tower property gives E[Zk∣Fk−1]=E[W∣Fk−1]=Zk−1, where Fk=σ(X1,…,Xk). This is the Doob martingale of W. The construction itself does not require independent inputs.
This converts a deviation of f into a sum of changes in conditional predictions. To prove concentration, we need to control how much one new observation can change that prediction.
Theorem 4 (Azuma–Hoeffding with conditional range bounds) Let (Zk)k=0n be a martingale. Suppose there are Fk−1-measurable endpoints ak,bk and deterministic constants ck≥0 such that ak≤Zk−Zk−1≤bk,bk−ak≤ck. If C=∑kck2>0, then, for every t>0, P(∣Zn−Z0∣≥t)≤2e−2t2/C. Each one-sided bound omits the factor 2. In particular, the assumption ∣Zk−Zk−1∣≤dk gives 2exp(−t2/(2∑kdk2)).
Proof. Write Dk=Zk−Zk−1. Conditional on Fk−1, the variable Dk has mean zero and lies in an interval of length at most ck. Hoeffding’s lemma, applied to this conditional distribution, gives E[eλDk∣Fk−1]≤eλ2ck2/8. Because D1,…,Dk−1 are already known at time k−1, Eeλ∑j=1kDj=E[eλ∑j<kDjE[eλDk∣Fk−1]]≤eλ2ck2/8Eeλ∑j<kDj. Iterating yields Eeλ(Zn−Z0)≤eλ2C/8. The same exponential Markov argument as before, with λ=4t/C, proves the upper tail; use −λ for the lower tail.
Notice the distinction between an absolute increment bound and a conditional range length. A variable in [−1,1] has range length 2, not 1. Tracking the conditional range is what gives the sharp constant in the next application.
Bounded differences: McDiarmid’s inequality
Suppose X1,…,Xn are independent. A function f has coordinate bounded differencesc1,…,cn if changing just coordinate i changes its value by at most ci. Writing x(i←y) for x with coordinate i replaced by y, this is ∣f(x)−f(x(i←y))∣≤ci. The condition is imposed on the product of the input spaces. It describes sensitivity to one input, rather than a Euclidean Lipschitz constant.
Theorem 5 (McDiarmid’s inequality) For independent inputs and an integrable function with coordinate bounded differences c1,…,cn, put C=∑ici2>0. Then, for t>0, P(∣f(X)−Ef(X)∣≥t)≤2e−2t2/C.
Proof. Use the Doob martingale Zi=E[f(X)∣X1,…,Xi]. Write x<i=(x1,…,xi−1) and X>i=(Xi+1,…,Xn). Fix the past x<i and define hi(u)=E[f(x<i,u,X>i)]. Independence means that the future inputs in this expectation have the same distribution for every value of u. Couple the two expectations using the same future inputs. The bounded-difference assumption then gives ∣hi(u)−hi(v)∣≤ci. Conditional on the past, Zi=hi(Xi) and Zi−1 is the conditional average of hi(Xi). Subtracting that average does not change the length of its range. Hence the conditional range of Zi−Zi−1 has length at most ci, and Theorem 4 applies.
Example 1 (Empty bins) Throw m≥1 balls independently and uniformly into n≥2 bins. Let Y be the number of empty bins. The empty-bin indicators are dependent, but linearity of expectation still gives EY=n(1−n1)m. Use the positions of the m balls as independent inputs. Moving one ball can empty its old bin or fill its new bin. If both occur, the changes cancel; in all cases the total number of empty bins changes by at most 1. McDiarmid therefore gives P(∣Y−EY∣≥t)≤2e−2t2/m. The denominator counts independent input coordinates—balls, not bins.
Example 2 (Sampling without replacement) A bag contains N balls, of which r are red. Draw n<N balls without replacement, let Yi indicate that draw i is red, and put Si=∑j=1iYj. We want concentration for Sn, whose mean is nr/N.
The Doob prediction after i observations is Zi=Si+(n−i)N−ir−Si. Let qi=(r−Si−1)/(N−i+1) be the conditional probability of red at draw i. Direct subtraction gives Zi−Zi−1=N−iN−n(Yi−qi). Given the past, this increment lies in an interval of length (N−n)/(N−i)≤1. Hence P(Sn−Nnr≥t)≤2e−2t2/n. If n=N, the total number of red balls drawn is exactly r and no concentration estimate is needed.
Example 3 (Choosing what to reveal: the chromatic number) Let G∼G(n,p) and let χ(G) be its chromatic number. Revealing all (2n) independent edge indicators gives a bounded-difference constant 1 for each edge, but only yields a deviation scale of order n.
There is a better representation. For i=1,…,n, let Xi encode the edges from vertex i to vertices 1,…,i−1. These n inputs are independent because they contain disjoint sets of edge indicators. Changing Xi changes only edges incident to vertex i.
Two such graphs have the same graph after deleting vertex i. Each chromatic number lies between the chromatic number of that common graph and one more. Their difference is therefore at most 1. McDiarmid now gives P(∣χ(G)−Eχ(G)∣≥t)≤2e−2t2/n. The gain comes from choosing a more informative unit of exposure.
2.2 Sub-Gaussian random variables
Recall the calculation underlying Hoeffding. For a centered variable, a quadratic upper bound on its log-MGF led to a Gaussian-shaped tail. Boundedness was one way to obtain that upper bound; it need not be the only way.
For an integrable X, write ψX(λ)=logEeλ(X−EX), allowing the value +∞ if the MGF diverges.
Definition 2 (Sub-Gaussian variables) We call Xσ2-sub-Gaussian if, for every λ∈R, ψX(λ)≤2λ2σ2. The number σ2 is a variance proxy. It is an upper bound on Var(X), but need not equal it.
Exponential Markov, optimized at λ=t/σ2, immediately gives, when σ2>0, P(∣X−EX∣≥t)≤2e−t2/(2σ2). For proxy zero, X is constant almost surely.
Example 4 (Gaussian, bounded, and Rademacher variables) If X∼N(μ,σ2), completing the square in the Gaussian integral gives ψX(λ)=λ2σ2/2 exactly.
If X∈[a,b], Hoeffding’s lemma gives variance proxy (b−a)2/4.
In particular, a uniform random sign ξ∈{−1,1} has proxy 1. One can also see this from Eeλξ=coshλ≤eλ2/2.
Addition and the role of independence
If Xi are independent with proxies σi2, then for deterministic real weights wi, ψ∑iwiXi(λ)=i∑ψXi(wiλ)≤2λ2i∑wi2σi2. Thus independent variances add at the level of proxies. Hoeffding’s inequality is a special case.
Without independence, this sum-of-squares rule can fail. For example, X1=⋯=Xn=ξ gives ∑iXi=nξ, whose variance is n2. A useful general comparison follows from Cauchy–Schwarz: if X,Y have proxies σX2,σY2, with arbitrary dependence, then Eeλ[(X−EX)+(Y−EY)]≤(Ee2λ(X−EX))1/2⋅(Ee2λ(Y−EY))1/2≤eλ2(σX2+σY2). This gives proxy 2(σX2+σY2) rather than σX2+σY2.
From one variable to a finite family
Suppose Z1,…,ZN are centered and each has proxy at most σ2>0. A union bound gives P(j≤Nmax∣Zj∣≥t)≤2Ne−t2/(2σ2). There is no independence assumption between the Zj here. For example, distance errors in a random projection can be highly dependent, but a pointwise tail bound still combines with a union bound over a finite set of pairs.
The expected maximum admits a related bound. For λ>0, Ejmax∣Zj∣≤λ1logEeλmaxj∣Zj∣≤λ1logj∑E(eλZj+e−λZj)≤λlog(2N)+2λσ2. Optimizing gives Emaxj∣Zj∣≤σ2log(2N).
Tail and moment descriptions of sub-Gaussian variables are equivalent to the MGF description up to universal changes in constants. For example, the displayed tail bound implies, for p≥1, E∣X−EX∣p=p∫0∞tp−1P(∣X−EX∣>t)dt≤2p∫0∞tp−1e−t2/(2σ2)dt, which gives (E∣X−EX∣p)1/p≤Cσp for a universal C. The reverse implications and precise parameter comparisons can be found in Vershynin’s High-Dimensional Probability, Chapter 2. We use the MGF convention throughout these notes.
2.3 Sub-exponential variables and Bernstein bounds
A useful variable may fail to have an MGF for all real parameters. The square of a Gaussian is the simplest example. If g∼N(0,1) and Y=g2, direct integration gives Eeλ(Y−1)={e−λ(1−2λ)−1/2,+∞,λ<1/2,λ≥1/2. So g2 is not sub-Gaussian. Nevertheless, its log-MGF is quadratic near zero. We can still run the Chernoff argument, with a restricted choice of parameter.
Definition 3 (Sub-exponential variables: a two-parameter convention) For ν>0 and α>0, call X(ν,α)-sub-exponential if ψX(λ)≤2νλ2for ∣λ∣≤α1. Here ν is a variance-scale parameter and α limits the MGF’s usable range. Some references write ν2 in place of our first parameter; the convention matters when adding variables.
For Y=g2, expanding the logarithm and bounding absolute values gives, when ∣λ∣≤1/4, ψY(λ)=21k=2∑∞k(2λ)k≤λ2j=0∑∞(2∣λ∣)j=1−2∣λ∣λ2≤2λ2. Thus g2 is (4,4)-sub-exponential. The absolute values ensure that the calculation also applies to negative λ.
Proposition 4 (Two tail regimes) If X is (ν,α)-sub-exponential, then, for every t>0, P(∣X−EX∣≥t)≤2exp[−21min{νt2,αt}]. The quadratic regime ends at t=ν/α.
Proof
For 0<λ≤1/α, exponential Markov gives exp(−λt+νλ2/2) for the upper tail. If t≤ν/α, choose λ=t/ν and obtain e−t2/(2ν). If t>ν/α, choose λ=1/α and use −αt+2α2ν≤−2αt. Apply the same argument to −X and add the bounds.
For independent (νi,αi)-sub-exponential variables, the weighted sum S=∑iwiXi has parameters νS=i∑wi2νi,αS=imax∣wi∣αi. Indeed, ∣λ∣≤1/αS puts every wiλ in its admissible interval, and the log-MGFs add. Zero weights can be omitted; if all weights vanish, the sum is deterministic.
Example 5 (The length of a Gaussian vector) For independent standard Gaussians g1,…,gd, the squared norm Q=∑igi2 has mean d and sub-exponential parameters (4d,4). Therefore, P(∣Q−d∣≥t)≤2exp[−min{8dt2,8t}]. For 0<ε<1, P(∣Q/d−1∣≥ε)≤2e−dε2/8. On the complementary event, d(1−ε)≤∥g∥2≤d(1+ε). This is a useful precursor to the Gaussian random projections used in the JL lemma.
Using variance information for bounded variables
Hoeffding uses the range of each variable but not its variance. If an event is rare, that can lose useful information, as our Bernoulli example showed. A more careful MGF expansion retains the variance.
Theorem 6 (Bernstein’s inequality) Let Xi be independent, with EXi=0 and ∣Xi∣≤b for b>0. Set V=∑iEXi2>0. Then, for t>0, P(i∑Xi≥t)≤2exp(−2(V+bt/3)t2). If V=0, every Xi vanishes almost surely.
Proof
Write vi=EXi2. For every integer k≥2, E∣Xi∣k≤vibk−2. Also k!≥2⋅3k−2. For ∣λ∣b<3, the power series therefore gives EeλXi≤1+k=2∑∞k!∣λ∣kvibk−2≤1+2(1−b∣λ∣/3)viλ2. Using log(1+x)≤x and independence yields logEeλ∑iXi≤2(1−b∣λ∣/3)Vλ2. For the upper tail take λ=t/(V+bt/3), which is strictly less than 3/b. Substitution into exponential Markov gives the claimed exponent. Repeat for the negative sum.
For example, each centered bounded Xi above is also (2vi,2b)-sub-exponential when vi>0, by restricting to ∣λ∣≤1/(2b). The corresponding sum has the two-regime transition at t=V/b. The smoother Bernstein bound retains more of the MGF estimate.
Example 6 (All degrees in a random graph) In G(n,p), the degree Dv of a fixed vertex has mean μ=(n−1)p and variance v=(n−1)p(1−p). Put x=log(2n/δ) and t=2vx+32x. Since t2≥2x(v+t/3), Bernstein gives P(∣Dv−μ∣≥t)≤2e−x. A union bound over vertices gives P(vmax∣Dv−μ∣≥t)≤δ. The degrees are dependent, but the union bound does not require their independence. The linear x term is essential in sparse regimes; it cannot be dropped without an additional assumption comparing np with logn.
2.4 Upper Confidence Bounds
ETC explores every arm for the same number of rounds. Ideally, an arm with a large gap Δi should receive fewer observations than an arm whose mean is close to the optimum. But the gaps are unknown. Can observations themselves tell us when an arm has been explored enough?
UCB answers this using optimism. Keep a plausible upper bound on each mean, and choose the arm with the largest upper bound. An arm is attractive either because its observed rewards are high, or because it has been sampled too little to rule out a high mean.
Confidence intervals under adaptive sampling
Use the bounded stochastic bandit model from Part I, with T≥K≥2. For each arm i, imagine an independent infinite reward stream Xi,1,Xi,2,… sampled in advance. The sth time arm i is pulled, reveal Xi,s. Define the fixed-prefix means μi,s=s1j=1∑sXi,j. For 0<δ<1, let ℓ=logδ2KT,rs=2sℓ. For each fixed (i,s) with 1≤s≤T, Hoeffding bounds the probability of ∣μi,s−μi∣>rs by δ/(KT). Taking a union bound gives P(G)≥1−δ, where G=i=1⋂Ks=1⋂T{∣μi,s−μi∣≤rs}. This event holds simultaneously for every possible sample count. We may therefore evaluate it at the random count Ni(t) chosen by the policy. Applying a fixed-sample Hoeffding bound directly at an adaptive random sample size would skip this justification.
The algorithm
Pull each arm once. After t≥K rounds, choose at round t+1 an arm maximizing Ui(t)=μi,Ni(t)+rNi(t). Break ties by any fixed rule. The policy here is a horizon-aware version of UCB; use δ=1/T, so ℓ=log(2KT2), for the regret guarantees below.
How many times can a suboptimal arm be selected?
On G, an optimal arm always has index at least μ∗. If arm i is selected after initialization, its index is at least that of an optimal arm. At that moment, μ∗≤Ui(t)≤μi+2rNi(t). Thus, for Δi>0, Δi≤22Ni(t)ℓ⟹Ni(t)≤Δi22ℓ. This is the number of samples before the next pull. Consequently, Ni(T)≤1+Δi22ℓon G. No gap was given to the algorithm; the analysis uses the true gap to explain when the confidence interval becomes narrow enough.
Theorem 7 (Regret of the horizon-aware UCB policy) In the bounded stochastic bandit model with T≥K≥2, set ℓ=log(2KT2). The policy above satisfies RT≤i:Δi>0∑(Δi+Δi2ℓ)+1. It also satisfies, for every ε>0, RT≤Tε+K+ε2Kℓ+1, and therefore RT=O(KTlogT).