AI Wiki中文/EN

Concentration inequalities

集中不等式

Compare finite-sample guarantees with exact tails and keep their assumptions visible.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

How unlikely is a large estimation error?

An average test loss differs from its population mean. A concentration inequality bounds the chance that the difference exceeds a chosen tolerance, using assumptions about the observations. It can provide a finite-sample guarantee without an asymptotic normal approximation.

The price of generality is looseness. A bound can be correct and much larger than the actual probability. We will compare two bounds with an exact binomial tail, showing that one familiar bound is not always sharper than another.

Read expectation and variance, independence and laws of large numbers first.

Each inequality spends different information

For a nonnegative random variable Z with finite mean and threshold a>0, Markov’s inequality is:

Pr⁡(Z≥a)≤E[Z]a.\Pr(Z\ge a)\le\frac{\mathbb E[Z]}{a}.

On the event Z≥a, the variable contributes at least a. Taking expectations of Z≥a times that event’s indicator proves the bound. Nonnegativity is essential. Apply it to the squared deviation of a variable with finite variance to obtain Chebyshev for positive t and ε:

Pr⁡(∣X−μ∣≥t)≤Var⁡(X)t2,Pr⁡(∣X‾n−μ∣≥ϵ)≤σ2nϵ2.\Pr(|X-\mu|\ge t)\le\frac{\operatorname{Var}(X)}{t^2},\qquad \Pr(|\overline X_n-\mu|\ge\epsilon)\le\frac{\sigma^2}{n\epsilon^2}.

The second form assumes IID observations with mean μ and variance σ², so their average has variance σ²/n. The MIT lecture on inequalities and the weak law develops this connection. A variance estimate plugged into a bound is not automatically the known population variance required by that theorem.

For independent observations bounded in [0,1], Hoeffding instead uses the range:

Pr⁡(∣X‾n−E[X‾n]∣≥ϵ)≤2e−2nϵ2.\Pr\left(\left|\overline X_n-\mathbb E[\overline X_n]\right|\ge\epsilon\right) \le 2e^{-2n\epsilon^2}.

Identical distributions are not needed for this bounded version; independence is. One derivation applies Markov to an exponential of the centered sum, factors its expectation by independence, bounds each factor using boundedness, and optimizes the exponential parameter. CS229’s learning-theory notes use the Bernoulli case and a union bound to control learning errors.

All displayed bounds can be clipped at one. A formula above one is valid but uninformative, not a probability greater than one.

Compare on a distribution with an exact answer

Let Xᵢ be independent Bernoulli(1/2), n=20. Then the success count K is binomial, the sample mean is K/20, and the exact tail is a finite sum of probabilities for counts satisfying the requested deviation. Its variance is 1/(4n).

For ε=1/5, Chebyshev is 0.3125 while Hoeffding is about 0.4038; Chebyshev is sharper here. For ε=3/10, Hoeffding becomes sharper. Neither bound needs to equal the exact tail. Comparing exponential and polynomial forms without their constants and operating point can be misleading.

To ensure the Hoeffding bound is at most δ, choose n at least log(2/δ)/(2ε²). At ε=0.1 and δ=0.05, 185 observations are sufficient under the stated assumptions. This is a sufficient bound, not proof that 184 observations cannot work for a particular distribution.

Enumerate the exact tail without boundary rounding

Run the complete Python 3.12 standard-library program. It accepts 1–200 samples and a rational tolerance in (0,1]. Fraction comparisons keep events exactly on the threshold inside the tail. Only the exponential bound and displayed decimal approximations use floats. This is exact enumeration of a known probability model, not a Monte Carlo simulation.

from fractions import Fraction as F
from math import comb,exp,ceil,log


def compare(n,epsilon):
    if type(n) is not int or not 1 <= n <= 200:
        raise ValueError('integer sample size in [1,200] required')
    if type(epsilon) not in (int,F) or not 0 < epsilon <= 1:
        raise ValueError('rational epsilon in (0,1] required')
    epsilon=F(epsilon)
    exact=sum((F(comb(n,k),2**n) for k in range(n+1)
               if abs(F(k,n)-F(1,2)) >= epsilon),F(0))
    chebyshev=min(F(1),F(1,4*n)/epsilon**2)
    hoeffding=min(1.0,2*exp(-2*n*float(epsilon)**2))
    return exact,chebyshev,hoeffding


if __name__ == '__main__':
    for epsilon in [F(1,5),F(3,10)]:
        exact,cheb,hoeff=compare(20,epsilon)
        print('epsilon='+str(epsilon),'exact='+format(float(exact),'.6f'),
              'Chebyshev='+format(float(cheb),'.6f'),'Hoeffding='+format(hoeff,'.6f'))
    required=ceil(log(2/0.05)/(2*0.1**2))
    print('Hoeffding sufficient n for epsilon=0.1, delta=0.05:',required)
    assert required==185

Output:

epsilon=1/5 exact=0.115318 Chebyshev=0.312500 Hoeffding=0.403793
epsilon=3/10 exact=0.011818 Chebyshev=0.138889 Hoeffding=0.054647
Hoeffding sufficient n for epsilon=0.1, delta=0.05: 185

The tail event uses “greater than or equal.” Replacing rational count comparisons with rounded decimals can accidentally exclude boundary counts. The implementation evaluates n+1 binomial masses. Its arithmetic count is linear in the number of counts, excluding the cost of integer binomial coefficients and growing rational numerators.

The guarantee belongs to the sampling procedure

A fixed-sample bound does not automatically apply after repeatedly inspecting data and stopping when a result looks favorable. Dependent observations also invalidate the simple independence-based formula. There are specialized bounds for dependent or sequential settings, with additional assumptions.

Testing many candidates requires simultaneous control when the claim concerns the chosen best candidate. A union bound allocates error probability across candidates; treating each individual guarantee as if it automatically covered the selection step is incorrect. See generalization.

The bounds concern randomness under a model. They do not repair distribution shift, wrong labels or biased sampling. A tight statement about an unrepresentative population can still be irrelevant to deployment.

Check assumptions before comparing constants

  1. Why does Markov require a nonnegative variable?

Answer 1: Its proof uses Z≥a times the event indicator everywhere. Negative values outside the event would violate that pointwise inequality.

  1. Why does the sample-mean Chebyshev bound have n in the denominator?

Answer 2: Independence removes cross-covariances and gives variance σ²/n for the average of IID observations.

  1. Is Hoeffding always tighter than Chebyshev?

Answer 3: No. In the n=20, ε=1/5 example, Chebyshev’s 0.3125 is below Hoeffding’s approximately 0.4038.

  1. Does the sufficient sample size 185 prove that every distribution needs at least 185 observations?

Answer 4: No. It is a distribution-free sufficient condition under the bounded independent model. Additional distribution information may yield a smaller sufficient sample size.

Use finite-sample bounds alongside exact models

The MIT notes explain moment-based inequalities, and CS229 shows how bounded-observation inequalities enter learning theory. Exact binomial enumeration here calibrates how conservative those guarantees can be.

As a project, sweep rational ε values and plot the exact tail against both bounds. Then change the Bernoulli probability and compare the effect of its actual variance with the range-only guarantee. Preserve the event convention and sampling assumptions in every plot.

Make a prediction, then check

Does a sufficient distribution-free sample size prove necessity for every distribution?

Choose one answer

Learning objectives

  • Derive moment bounds and state bounded-sample assumptions.
  • Compare sufficient bounds with exact binomial probabilities.

Prerequisites & connections

Explore related knowledge →

References

  1. Introduction to Probability — Lecture 18: Inequalities, Convergence, and the Weak Law of Large Numbers
    John Tsitsiklis; Patrick Jaillet; MIT OpenCourseWare · 2018
  2. CS229 Lecture Notes — Part VI: Learning Theory
    Andrew Ng

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-06 · Codex single-agent authored technical review: primary-source locations, explicit assumptions, derivations, exact/literal and numerical checks, and bilingual review; not independent human or second-agent peer review.

  • Single-agent authored technical review: primary-source locations, explicit domains and assumptions, derivations, literal/exact probability or numerical reference cases, bilingual examples and exercises. Not independent human or second-agent review.
  • Four focused tests passed on CPython3.12.4; NumPy1.26.4 actually executed for the Fourier chapter. Exact rational probability/stencil checks are distinguished from floating-point calculations and observed Monte Carlo output. Both languages render three equations, six anchors and four answers; final repository checks recorded separately.
  • Promoted the full prose, equations, code and exercises. Tests read formal MDX only; removed temporary fallbacks/draft skips and updated review assertion to checked. Algorithm and independent references are unchanged; final record binds both locale hashes.
  • Publication navigation points published topics to complete articles and removes corresponding pending wording, retaining directory entries for unwritten targets. Principles, equations, programs and exercises are unchanged; final article SHA values rebound.
  • Final prose review made positivity of both Chebyshev deviation thresholds explicit; formulas and executable programs unchanged.

Source locations checked:

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.