Probability & Concentration Inequalities
From the law of large numbers to Hoeffding and Bernstein.
Every guarantee in learning theory comes down to one question: how far can an average of random quantities stray from its mean? The law of large numbers says "eventually, not far." Concentration inequalities say exactly how far, at every sample size, with explicit probabilities. This lesson builds them from Markov's inequality up and turns them into the first generalization bound.
What you’ll learn
- Prove Markov's and Chebyshev's inequalities and the weak law of large numbers, and explain why the central limit theorem cannot replace a finite-sample bound.
- Derive the Chernoff method, Hoeffding's lemma and Hoeffding's inequality, and relate them to the KL form of the Chernoff bound.
- Define sub-Gaussian variables, bound the expected maximum of of them, and state Bernstein's and McDiarmid's inequalities with their conditions.
- Combine Hoeffding's inequality with the union bound to prove that, with probability , every hypothesis in a finite class satisfies .
From Markov to the law of large numbers
Markov. For a nonnegative random variable and , the pointwise inequality holds; take expectations:
Chebyshev. Apply Markov to , where and :
The weak law. For the mean of i.i.d. copies, , so the probability of any fixed deviation vanishes, which is the weak law of large numbers:
The central limit theorem describes the shape of the fluctuations: converges in distribution to . It is a limit statement, though, not a bound. The Berry–Esseen theorem quantifies the approximation, with an absolute constant below , and an error of order is useless for certifying tail probabilities like .
Learning theory needs exactly such tiny tails, because it controls many averages at once: one per hypothesis. Chebyshev's dependence is too weak for that, as the next step shows. What is needed are inequalities whose tails decay exponentially in , with explicit constants, valid at every : concentration inequalities.
The Chernoff method and Hoeffding's inequality
The Chernoff method. For any , Markov's inequality applied to gives , and the bound can then be optimized over . For a sum of independent variables the moment generating function factorizes, , so everything reduces to bounding one factor.
Let with , so . Since is convex, on it lies below its chord; take expectations, using :
Here , and . Direct differentiation gives and with . Taylor's theorem with remainder then gives:
You estimate the mean of a -valued variable from i.i.d. samples. How many samples does Hoeffding's inequality require to guarantee with probability at least 95%?
Show the answer
738 samples
Solve : , so 738. Chebyshev, with the worst-case variance , needs . The CLT approximation suggests about 385, but it is not a guarantee. The gap widens as shrinks: at , Hoeffding needs 2,902 samples and Chebyshev , because Hoeffding pays where Chebyshev pays .
For Bernoulli variables the Chernoff method can be pushed to the exact optimum, which gives a bound in terms of the KL divergence between Bernoulli distributions: , a result also due to Hoeffding (1963). The technique carries Chernoff's name from his 1952 paper, although Chernoff himself attributed the bound to Herman Rubin. Pinsker's inequality gives , so the KL form is never weaker than Hoeffding's, and it is much stronger near the boundary: for and the exponent per sample is instead of . Information Theory for ML develops the KL divergence and what it measures.
Sub-Gaussian variables, maxima and Bernstein
Let be mean-zero and sub-Gaussian with variance proxy , not necessarily independent. For , Jensen's inequality ( is convex), then bounding a maximum of nonnegative terms by their sum:
Take logarithms and divide by :
Choose . The maximum of such variables grows only like the square root of . This is the source of the in the regret of exponential weights and of the in the Rademacher complexity of a finite class (Massart's lemma):
Hoeffding's inequality implicitly assumes the worst variance a bounded variable can have, . Bernstein's uses the actual one, and the difference is dramatic for rare events, such as estimating a small error rate, a click-through rate or a failure probability, where is tiny.
A classifier's error rate is about . You want to estimate it to within with 95% confidence. Compare the sample sizes guaranteed by Hoeffding's and Bernstein's inequalities.
- Hoeffding needs fewer, because Bernstein's extra term costs samples
- They need the same number, since both are exponential bounds
- Bernstein needs about half as many
- Bernstein needs about 20 times fewer: about 3,400 against about 74,000
Show the answer
D. Bernstein needs about 20 times fewer: about 3,400 against about 74,000
Hoeffding: . Bernstein, with and : . The variance is 25 times smaller than Hoeffding's implicit , and the linear term costs little at this .
Bounded differences, the union bound and generalization
Reveal the variables one at a time. The Doob martingale runs from to , so the deviation is a sum of increments:
Given , the increment is a function of alone (the later variables are averaged out, and they are independent of ), with conditional mean zero; the bounded-difference property confines it to an interval of length at most . Hoeffding's lemma applies conditionally:
Peel off one increment at a time with the tower property, then apply the Chernoff method with (this is the Azuma–Hoeffding inequality):
For a loss with values in , the worst-case gap changes by at most when one example of changes, whatever the class. McDiarmid therefore pins within of its mean, and the whole difficulty of learning theory moves into bounding , which is what VC dimension and Rademacher complexity do in the Generalization & Model Selection topic. For a finite class, a cruder tool suffices: the union bound, .
Fix before seeing the data. Its losses on the examples are i.i.d. in with mean , so Hoeffding's inequality gives
The hypothesis that training selects depends on the data, so a bound for each fixed is not enough. The union bound over all of covers whichever one is selected:
Set the right side to and solve for . On the resulting event, chain the inequalities for ERM's choice and the best hypothesis :
Think first With hypotheses, examples and , how large is ? What happens if the class grows to hypotheses?
and , so : every one of a million hypotheses has its training error within 3 points of its true error, and ERM is within 6 points of the best. Squaring the class to only doubles , and grows to about . Exponential tails make the union bound cheap; for infinite classes, is replaced by the VC dimension or a Rademacher complexity, and No Free Lunch & Inductive Bias explains why some such restriction is unavoidable.
Key takeaways
- Markov () and Chebyshev () give the weak law of large numbers; the central limit theorem gives the shape of the fluctuations but, with an error of order , no usable tail bounds.
- The Chernoff method plus Hoeffding's lemma, , gives Hoeffding's inequality : about samples, against Chebyshev's . For Bernoulli means, the KL form is never weaker.
- Sub-Gaussian variables have Gaussian-type tails, and the maximum of of them has mean at most , the source of logarithmic dependence on the number of experts or hypotheses.
- Bernstein's inequality uses the true variance and wins by large factors for rare events; McDiarmid's inequality extends Hoeffding to any function of independent variables with bounded differences, including the worst-case gap over a hypothesis class.
- Hoeffding plus the union bound gives uniform convergence for finite classes, , and ERM within of the best hypothesis.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
To guarantee with probability at least for variables in , how does the required scale with under Chebyshev's and under Hoeffding's inequality?
- Both like
- Chebyshev like , Hoeffding like
- Chebyshev like , Hoeffding like
- Neither depends on
Show the answer
B. Chebyshev like , Hoeffding like
Chebyshev's tail decays only polynomially in , so ; Hoeffding's tail decays exponentially, so . That logarithm is what lets union bounds over many events stay cheap.
When does Bernstein's inequality give a much smaller sample size than Hoeffding's for estimating a mean?
- When the variables are unbounded
- When the required accuracy is very large
- Never: Hoeffding's inequality is always at least as sharp
- When the variance is much smaller than the squared range, as for rare events
Show the answer
D. When the variance is much smaller than the squared range, as for rare events
Bernstein's exponent is , Hoeffding's . When and is small compared with , Bernstein's exponent is far larger, by up to the ratio of the worst-case variance to the true one.
Why does , for a loss in , concentrate around its mean even when is infinite?
- Because each concentrates by Hoeffding, and a supremum of concentrated variables is concentrated
- Because the central limit theorem applies to suprema
- Because changing one example changes every , hence , by at most , so McDiarmid's inequality applies with
- It does not: concentration requires a finite class
Show the answer
C. Because changing one example changes every , hence , by at most , so McDiarmid's inequality applies with
McDiarmid needs only bounded differences, and has them with regardless of the size of : . The class enters only through the mean , which is what Rademacher complexity bounds.
In the bound , why does the size of the class enter only through its logarithm?
- Because the union bound multiplies the failure probability by , and an exponential tail absorbs that factor at the cost of adding to
- Because hypotheses in a large class are highly correlated, so they count as fewer
- Because ERM only ever evaluates one hypothesis
- Because of the central limit theorem
Show the answer
A. Because the union bound multiplies the failure probability by , and an exponential tail absorbs that factor at the cost of adding to
Solving gives . With Chebyshev's polynomial tail instead, the union bound would cost a factor in , which is why exponential concentration is the engine of learning theory.
Further reading
- W. Hoeffding, "Probability inequalities for sums of bounded random variables," Journal of the American Statistical Association 58(301), 13–30 (1963).
- C. McDiarmid, "On the method of bounded differences," in Surveys in Combinatorics, 1989 (Cambridge University Press, 1989), 148–188.
- S. Boucheron, G. Lugosi & P. Massart, Concentration Inequalities: A Nonasymptotic Theory of Independence (Oxford University Press, 2013).
- R. Vershynin, High-Dimensional Probability: An Introduction with Applications in Data Science (Cambridge University Press, 2018), chapter 2.
- G. Lugosi & S. Mendelson, "Mean estimation and regression under heavy-tailed distributions: a survey," Foundations of Computational Mathematics (2019).