Foundations to Frontier
Tests
B. Statistical Learning Theory › B2 Generalization theory

Finite Hypothesis Classes and the Union Bound

For a finite set of hypotheses, one simple inequality gives learning guarantees: the union bound, P(A₁ ∪ … ∪ A_K) ≤ Σ P(Aᵢ). This topic derives realizable and agnostic sample complexities for finite classes, Occam's razor (hypotheses describable in b bits need about b examples per unit of accuracy), the weighted union bound that gives simpler hypotheses tighter guarantees (structural risk minimization), and the discretization trick for continuous parameters. In the research exercise you learn Boolean conjunctions with the elimination algorithm, then measure when the union bound is nearly tight (independent hypotheses) and when it wastes most of its slack (correlated thresholds).

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Many chances to be fooled

If you test one coin for bias with 100 flips, being badly fooled is rare. If you test a thousand coins, some coin will look biased just by luck. A learner that picks the best of many hypotheses faces the same risk: one of them might look good on the training data by accident. The union bound says the chance that any of them fools you is at most the sum of the individual chances. So the more hypotheses you consider, the more data you need, though only logarithmically more.

When is the union bound tight?
union bound0.140random tables0.116thresholds0.088
95th-percentile worst gap: random tables 83% of the union bound, thresholds 63%
Both classes have the same size K, so the union bound √(ln(2K/δ)/2m) treats them the same. Random-table classifiers make nearly independent mistakes, so with many of them one is likely to look much better or worse on the sample than it really is: the bound is nearly tight. Thresholds overlap heavily (neighbours agree on almost every point), so the class behaves as if it had only a few effectively different members. Capturing that "effective size" is what VC dimension and Rademacher complexity do (b2-3, b2-4).
Why engineers care

Every time you tune hyperparameters, try many models or test many features against the same validation data, you are choosing from a finite class, and the union bound tells you how much your validation score is inflated. It is also why multiple-testing corrections (Bonferroni, a5-1-10) exist.

📝 Quick check (Level 0)
0/3 answered
  1. 1. The union bound says P(A or B) is at most…
  2. 2. Choosing among more hypotheses needs…
  3. 3. Trying 1000 models on one validation set makes the best score…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

Two bounds for finite H

  • Realizable (some h has zero error): any consistent learner has error ≤ ε with probability ≥ 1 − δ once m≥(ln⁡∣H∣+ln⁡(1/δ))/εm\ge(\ln|H| + \ln(1/\delta))/\varepsilon.
  • Agnostic: with probability ≥ 1 − δ, every h satisfies ∣R^(h)−R(h)∣≤ln⁡(2∣H∣/δ)/(2m)|\hat R(h) - R(h)|\le\sqrt{\ln(2|H|/\delta)/(2m)}, so ERM is within twice that of the best in class.

Example: conjunctions

Conjunctions of literals over n Boolean variables (like x₀ ∧ ¬x₃ ∧ x₇) number 3n+13^n + 1. The elimination algorithm starts with all 2n literals and deletes each one falsified by a positive example. It is consistent, so m≥(nln⁡3+ln⁡(1/δ))/εm\ge(n\ln3 + \ln(1/\delta))/\varepsilon suffices: 500 examples for n = 20 and ε = δ = 0.05.

📝 Quick check (Level 1)
0/3 answered
  1. 1. Number of conjunctions over 2 variables (plus 'always false'):
  2. 2. Realizable sample size grows with |H| as…
  3. 3. The elimination algorithm learns from…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 35 minUndergraduate students and practising engineers.

Occam’s razor

If every hypothesis can be written in b bits, then ∣H∣≤2b|H|\le2^b and m≥(bln⁡2+ln⁡(1/δ))/εm\ge(b\ln2 + \ln(1/\delta))/\varepsilon. Short descriptions mean few examples are needed (Blumer et al., 1987). A model with 1000 parameters stored as 16-bit numbers is a finite class of size 2160002^{16000}: a valid but loose bound (221 868 examples at ε = δ = 0.05).

The weighted union bound

Assign each hypothesis a prior weight w(h) with ∑hw(h)≤1\sum_hw(h)\le1 (for example from description length). Then, simultaneously for all h with probability ≥ 1 − δ,

∣R^(h)−R(h)∣≤ln⁡(1/w(h))+ln⁡(2/δ)2m.|\hat R(h) - R(h)|\le\sqrt{\frac{\ln(1/w(h)) + \ln(2/\delta)}{2m}}.

Simple hypotheses (large w) get tighter bounds. This works for countably infinite classes too. Structural risk minimization (Vapnik) picks the h minimizing training error plus this penalty, and it is the seed of PAC-Bayes (b2-8).

Looseness

The union bound treats every hypothesis as if its failure were independent of the others. When hypotheses are highly correlated (thresholds, nearby parameters), most of that slack is wasted. Effective class size is what VC dimension and Rademacher complexity measure.

🐍 Exercise 1: learning conjunctions
Implement the elimination algorithm for Boolean conjunctions over 20 variables. Check that it is consistent and keeps the target literals, then verify the Occam sample-size guarantee empirically and see it fail with too few examples.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Occam's bound for b-bit hypotheses:
  2. 2. In the weighted union bound, a hypothesis with larger prior weight gets…
  3. 3. The union bound is loosest when hypotheses are…

Level 3: Advanced

★★★★☆ Advanced⏱ 35 minGraduate level, with full derivations and proofs.

Proof: agnostic finite class

Hoeffding gives P(∣R^(h)−R(h)∣>ε)≤2e−2mε2P(|\hat R(h) - R(h)| > \varepsilon)\le2e^{-2m\varepsilon^2} for each h. The union bound over |H| hypotheses gives a total failure probability ≤2∣H∣e−2mε2\le2|H|e^{-2m\varepsilon^2}. Setting this equal to δ and solving for ε gives the formula. ∎

Proof: Occam’s razor

A b-bit description language describes at most 2^b hypotheses; apply the realizable finite-class bound with |H| = 2^b. ∎ Changing the language changes which hypotheses count as “simple”, which is exactly NFL’s inductive bias (b1-5).

Proof: weighted union bound

Give hypothesis h failure budget δ w(h)\delta\,w(h). Hoeffding at level δw(h)\delta w(h) gives its ε(h), and summing the budgets gives at most δ. ∎

📝 Quick check (Level 3)
0/3 answered
  1. 1. In the weighted union bound, each h gets failure budget…
  2. 2. Doubling |H| adds how many samples to the realizable bound at ε = 0.05?
  3. 3. Bits needed to describe a conjunction over 20 variables:

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

Conjunctions and the tightness of the union bound

Conjunctions (n = 20, target x₀ ∧ ¬x₃ ∧ x₇). The elimination algorithm with the Occam size m = 500 never exceeded ε = 0.05 in 200 runs; its mean error was essentially 0, because the bound is very conservative here. With m = 20, 96% of runs had error > ε, as spurious literals survive.

Union-bound tightness (|H| = 1024 hypotheses, m = 200 samples, 10% label noise). The union bound is 0.163. The 95th percentile of the worst gap is:

  • 0.137 (84% of the bound) for 1024 random-table classifiers, whose errors are nearly independent;
  • 0.097 (60%) for 1024 thresholds, which are highly correlated.

Weighted bound. Coarse thresholds (2 hypotheses at level 1) get ε = 0.113, fine ones (1024 at level 10) get 0.209. The simultaneous violation rate was 0, within the promised δ = 0.05.

🐍 Exercise 2 (research): how tight is the union bound?
Build two classes of 1024 hypotheses: correlated thresholds and nearly independent random-table classifiers. Measure the distribution of the worst empirical–true risk gap, compare with the union bound, and verify a weighted (Occam) union bound over nested threshold grids.

Finite classes in AI, robotics and aerospace

  • Model selection: hyperparameter search and leaderboard overfitting; the union bound quantifies how much the best validation score is inflated.
  • Rule learning: interpretable models (conjunctions, decision lists, small trees) for anomaly detection in telemetry, with Occam-style guarantees.
  • Compression-based bounds: quantized and pruned networks give much tighter Occam bounds than raw parameter counts.
  • Statistics: Bonferroni and Holm corrections for multiple hypothesis tests (a5-1-10).

References

  1. A. Blumer, A. Ehrenfeucht, D. Haussler, M. Warmuth (1987). “Occam’s razor.” Information Processing Letters, 24.
  2. S. Shalev-Shwartz, S. Ben-David (2014). Understanding Machine Learning, ch. 2–4, 7. Cambridge.
  3. M. Kearns, U. Vazirani (1994). An Introduction to Computational Learning Theory. MIT Press.
  4. V. Vapnik (1998). Statistical Learning Theory. Wiley.
  5. W. Zhou, V. Veitch, M. Austern, R. Adams, P. Orbanz (2019). “Non-vacuous generalization bounds at the ImageNet scale: a PAC-Bayesian compression approach.” ICLR.