Quant Memo
Advanced

Uniform Convergence of Empirical Risk

The law of large numbers promises that one model's training score converges to its true score. Learning needs something stronger — that every model in your class is measured accurately at once — and that stronger promise is what makes fitting from data safe.

Prerequisites: Empirical Risk Minimization, Hoeffding's Inequality, The Generalization Gap

You have 2,000 rows of data and a family of candidate models. You score every candidate on those rows and keep the best one. Then you want to say something honest about how the winner will behave tomorrow.

The law of large numbers looks like it should settle this. It says that for any fixed rule, the average loss on a growing sample converges to the true average loss. Apply that to the winner and you are done — except you cannot, because the winner was not fixed. It was selected because its score on those exact rows came out low, and rules whose scores come out low on a particular sample are exactly the rules whose scores on that sample are unrepresentative. The selection and the measurement used the same data, so the guarantee does not apply to the thing you care about.

The repair is to demand something stronger up front: that every rule in the class is measured accurately on this sample, all at the same time. If that holds, it holds for the winner too, whichever one the winner turns out to be. That property is uniform convergence, and it is the foundation the rest of statistical learning theory is built on.

The analogy: one coin, or a thousand

Flip a fair coin ten times. The chance of ten heads is 1/10241/1024, about 0.1%. If it happens, you would rightly suspect the coin.

Now flip a thousand fair coins ten times each and report the most extreme one. The chance that some coin in the room shows ten heads is about 62%. Nothing changed about any individual coin — each is still fair, each still has a 0.1% chance. What changed is that you gave yourself a thousand chances to be surprised and then reported only the surprise.

A hypothesis class is a room full of coins. Every hypothesis hh has its own small probability of looking much better on your sample than it truly is. Fitting a model means walking the room and picking the ten-heads coin. Uniform convergence is the statement that the room is small enough, relative to your sample, that no coin can look that lucky.

Writing it down

Recall the two quantities: the true risk R(h)R(h), the average loss over all future data, and the empirical risk R^S(h)\hat{R}_S(h), the average loss over your nn samples SS. The object that matters is not either one but the largest disagreement between them, taken over the whole class H\mathcal{H}:

suphHR^S(h)R(h)    ε\sup_{h \in \mathcal{H}} \big| \hat{R}_S(h) - R(h) \big| \;\le\; \varepsilon

The symbol sup\sup means "the largest value over all choices of hh" — the worst case, the least lucky hypothesis in the room. In words: no rule in the class, not one, is mismeasured by more than ε\varepsilon on this sample. A sample with that property is called ε\varepsilon-representative.

Why is that the right thing to want? Because it makes fitting safe, in three lines. Write h^\hat{h} for the rule that minimises empirical risk and hh^{*} for the genuinely best rule in the class:

R(h^)    R^S(h^)+ε    R^S(h)+ε    R(h)+2εR(\hat{h}) \;\le\; \hat{R}_S(\hat{h}) + \varepsilon \;\le\; \hat{R}_S(h^{*}) + \varepsilon \;\le\; R(h^{*}) + 2\varepsilon

Read it left to right. The first step uses ε\varepsilon-representativeness on h^\hat{h}. The second uses the fact that h^\hat{h} was chosen to have the lowest empirical risk, so it cannot be worse than hh^{*} on the sample. The third uses ε\varepsilon-representativeness again, this time on hh^{*}. Conclusion: the model you fitted is within 2ε2\varepsilon of the best one available, and you never had to know which model that was. No step is hand-waved and none needs anything beyond the definition.

risk, increasing to the right R̂(ĥ) R̂(h*) R(h*) R(ĥ) bound ERM picks lower ε ε fitted model is at most 2ε worse than the best in the class
The whole payoff of uniform convergence in one picture. Two applications of "no hypothesis is mismeasured by more than epsilon" sandwich the fitted model against the unknown best one.

Worked example 1: the room of coins, counted

One coin. Ten flips of a fair coin. Pr(ten heads)=(1/2)10=1/1024=0.000977\Pr(\text{ten heads}) = (1/2)^{10} = 1/1024 = 0.000977, so 0.098%.

A thousand coins. The probability that no coin shows ten heads is (10.000977)1000(1 - 0.000977)^{1000}. Take logs: 1000×ln(0.999023)=1000×(0.000977)=0.9771000 \times \ln(0.999023) = 1000 \times (-0.000977) = -0.977, and e0.977=0.376e^{-0.977} = 0.376. So

Pr(some coin shows ten heads)=10.376=0.624\Pr(\text{some coin shows ten heads}) = 1 - 0.376 = 0.624

62.4%. More likely than not. Every individual guarantee held perfectly and the collection still failed, because a guarantee that holds for each is not a guarantee that holds for all.

Notice what fixes it. If you had flipped each coin 100 times instead of 10, one coin's chance of all heads becomes 21002^{-100}, unimaginably small, and even a thousand of them cannot conjure a false positive. Bigger sample, same room, safe again. That trade — room size against sample size — is the whole subject.

The explorer below shows the honest, one-hypothesis picture: a running average settling on its true value inside a 1/n1/\sqrt{n} envelope. Uniform convergence is the demand that a thousand of these curves all stay inside their envelopes simultaneously.

Convergence explorer
true meansamples →
after n = 200estimate -0.025error 0.025std error 0.071

Worked example 2: how much data buys uniformity

Suppose the class H\mathcal{H} is finite with H|\mathcal{H}| members. Hoeffding bounds the failure probability for one hypothesis at 2e2nε22e^{-2n\varepsilon^2}. The union bound says the chance that at least one of several events happens is at most the sum of their chances, so

Pr(suphR^S(h)R(h)>ε)    2He2nε2\Pr\Big(\sup_{h} |\hat{R}_S(h) - R(h)| > \varepsilon\Big) \;\le\; 2|\mathcal{H}|\,e^{-2n\varepsilon^2}

In words: the risk of any hypothesis being badly mismeasured is at most the per-hypothesis risk multiplied by how many hypotheses there are. Set the right side to δ\delta and solve for nn:

n    ln(2H/δ)2ε2n \;\ge\; \frac{\ln(2|\mathcal{H}|/\delta)}{2\varepsilon^2}

Case A. A class of decision stumps: 100 features, 50 candidate thresholds each, two polarities, so H=10,000|\mathcal{H}| = 10{,}000. Demand ε=0.05\varepsilon = 0.05 with δ=0.05\delta = 0.05.

nln(2×10,000/0.05)2(0.05)2=ln400,0000.005=12.8990.005=2,580n \ge \frac{\ln(2 \times 10{,}000 / 0.05)}{2(0.05)^2} = \frac{\ln 400{,}000}{0.005} = \frac{12.899}{0.005} = 2{,}580

Case B. Now blow the class up a hundredfold to H=106|\mathcal{H}| = 10^{6}, keeping ε\varepsilon and δ\delta fixed.

nln(4×107)0.005=17.5040.005=3,501n \ge \frac{\ln(4 \times 10^{7})}{0.005} = \frac{17.504}{0.005} = 3{,}501

A hundredfold larger search space costs you 36% more data. That is the single most useful fact in this whole area: H|\mathcal{H}| enters through a logarithm, so richness is cheap, while accuracy enters through ε2\varepsilon^2, so precision is expensive. Halving ε\varepsilon to 0.025 in Case A takes nn from 2,580 to 10,319 — four times the data for twice the accuracy.

−ε the sup — and the one ERM will happily pick measurement error, one bar per hypothesis
Each bar is one hypothesis's gap between measured and true risk. Pointwise convergence only promises each bar shrinks. Uniform convergence promises the band holds every bar, including the deepest one — which is precisely the one empirical risk minimisation will select.

Uniform convergence is not "each hypothesis is measured well". It is "the worst hypothesis is measured well", and that stronger claim is what licenses choosing a model from data. Sample size buys accuracy quadratically (1/ε21/\varepsilon^2) and buys class size only logarithmically (lnH\ln|\mathcal{H}|).

What this means in practice

This is the formal version of "count your search". Every extra hyperparameter grid point, feature variant and seed is another coin in the room. The bound is generous about that — logarithms are forgiving — but it is not free, and the count that matters is everything you evaluated, not everything you reported.

Infinite classes are not automatically hopeless. Linear classifiers form an uncountable set and lnH\ln|\mathcal{H}| is meaningless, but on a sample of nn points only finitely many distinct labellings are achievable. Replacing H|\mathcal{H}| by that effective count is the road to VC Dimension and Rademacher Complexity.

Sequential dependence breaks the setup. Hoeffding assumed independent draws. Financial data is autocorrelated, so 2,000 daily observations carry far less information than 2,000 independent ones, and the effective nn in these formulas is smaller than the row count — often by an order of magnitude.

Use the shape, not the number. The absolute bounds are famously loose; a bound of 0.31 on a model with 12% test error tells you nothing you can act on. What is reliable is the scaling: four times the data for half the error, a hundred times the search for a third more data.

The classic error is treating pointwise convergence as if it were uniform. "For each hh, R^S(h)R(h)\hat{R}_S(h) \to R(h) as nn grows" is true under the law of large numbers and is useless here, because the hypothesis you end up using is a random function of the sample, not a fixed one — the limit statement never applies to it. A second, subtler trap runs the other way: uniform convergence is sufficient for learning, not necessary. Modern overparameterised networks interpolate their training data, have vacuous uniform-convergence bounds, and generalise anyway; see Benign Overfitting and Harmless Interpolation. So a loose or meaningless bound is not evidence that a model will fail — it is only the absence of evidence that it will succeed.

Practise it

  1. Fifty coins, eight flips each. What is the chance at least one shows all heads? (Answer: 1(11/256)50=10.8223=0.1781 - (1 - 1/256)^{50} = 1 - 0.8223 = 0.178.)
  2. With H=500|\mathcal{H}| = 500, ε=0.1\varepsilon = 0.1, δ=0.01\delta = 0.01, how many samples? (Answer: ln(100,000)/0.02=11.513/0.02=576\ln(100{,}000)/0.02 = 11.513/0.02 = 576.)
  3. You have n=5,000n = 5{,}000 and H=220|\mathcal{H}| = 2^{20}. With δ=0.05\delta = 0.05, what ε\varepsilon can you guarantee? (Answer: ln(2×220/0.05)=17.552\ln(2 \times 2^{20}/0.05) = 17.552, so ε=17.552/10,000=0.0419\varepsilon = \sqrt{17.552/10{,}000} = 0.0419.)
  4. Explain in one sentence why the 2ε2\varepsilon chain would break if you applied ε\varepsilon-representativeness only to h^\hat{h} and not to hh^{*}.

Related concepts

Practice in interviews

Further reading

  • Shalev-Shwartz & Ben-David, Understanding Machine Learning, ch. 4
  • Abu-Mostafa, Magdon-Ismail & Lin, Learning From Data, ch. 2
ShareTwitterLinkedIn