A1130 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

A11 · Lesson 30 · Tail bounds

Guarantees about rare events when you don't know the whole distribution

A buffer holds 10 packets and the average queue is 2: how often can it overflow? A test measured 20 000 bits: how sure can you be that the true error rate is within 1% of what you saw? Often you know a mean, maybe a variance or a generating function, but not the full distribution, and you need a guarantee, not a guess. Tail bounds give one. The more you know about a variable, the tighter the bound: the mean alone gives Markov's, the variance adds Chebyshev's, and the generating function (lesson 26) gives Chernoff's, which shrinks exponentially. Lesson 29's law of large numbers rests on them.

  • For a standard Gaussian, the curves are the true chance of landing at least k standard deviations above the mean, Q(k), and the bounds on it: Chebyshev's 1/k2 (for both tails together) and Chernoff's e−k2/2.
  • On the log scale the true tail and Chernoff's bound both curve down like parabolas; Chebyshev's only falls as a straight line, which is why it's so loose far out.

Predict

A queue holds 2 packets on average. Knowing only that, what can you say about the chance it holds 10 or more?

Name it

Markov's inequality

For a variable that's never negative,

P(X≥a)≤E[X]a

Proof: E[X]≥E[X⋅1X≥a]≥aP(X≥a).

Chebyshev's inequality

Apply Markov to (X−μ)2, with a=k2σ2:

P(|X−μ|≥kσ)≤1k2

for any distribution with a variance. It's why "within a few standard deviations" means something even for unknown distributions, and with σ2/n for an average of n samples it proves the law of large numbers.

Chernoff's bound

Apply Markov to esX for any s>0, then pick the best s:

P(X≥a)≤mins>0⁡e−saMX(s)

For a Gaussian with variance σ2 and mean 0, the minimum is at s=a/σ2 and gives e−a2/2σ2: exponentially small, like the true tail.

Hoeffding's bound for averages

For the average X¯ of n independent variables each between 0 and 1, such as error indicators,

P(|X¯−p|≥ε)≤2e−2nε2

whatever their distribution. Setting the right side to δ gives a sample size that guarantees accuracy ε with confidence 1−δ:

n≥ln⁡(2/δ)2ε2

Worked example

A buffer's queue averages 2 packets with a standard deviation of 1.5. Bound the chance it reaches 10.

Show the solution
  1. Markov, from the mean alone. P(Q≥10)≤2/10=0.2
  2. Chebyshev, using the variance. 10 is 8/1.5=5.33 standard deviations above the mean, so P(Q≥10)≤P(|Q−2|≥8)≤1/5.332=0.035
  3. Compare. The second bound is six times tighter because it uses more information. If the queue were known to be geometric, the exact answer would be smaller still, but neither bound needed that.

Answer Markov bounds the chance by 0.2, and Chebyshev by 0.035.

Worked example

Compare the bounds with the truth for a Gaussian at 3 and 4 standard deviations from the mean.

Show the solution
  1. At 3σ, Chebyshev. It bounds both tails together by 1/9=0.111
  2. At 3σ, the truth. 2Q(3)=0.0027 forty times smaller.
  3. At 4σ, Chernoff. It bounds one tail by e−8=3.4×10−4 against Q(4)=3.2×10−5: ten times too big, but with the right exponential shape.
  4. Which to use. For bit-error estimates that need the shape, Chernoff's bound is the useful one; Chebyshev's guarantee is for when you know nothing but the variance.

Answer at 3σ Chebyshev gives 0.111 against a true 0.0027; at 4σ Chernoff gives 3.4×10−4 against a true 3.2×10−5.

Worked example

A link's bit error rate is estimated by counting errors in n bits. How many bits guarantee the estimate is within 0.01 of the truth with 99% confidence, whatever the true rate?

Show the solution
  1. Hoeffding's bound. With ε=0.01 and δ=0.01: n≥ln⁡(200)2×10−4=26492bits
  2. What it guarantees. That's a distribution-free guarantee; for a rate as small as 10−3, where the variance is tiny, a sharper bound needs fewer bits, but the absolute accuracy 0.01 would then be useless anyway.
  3. Small rates. For small rates you specify relative accuracy, and need roughly 100/p bits or more.

Answer 26 492 bits guarantee it, whatever the true rate.

Check

A nonnegative quantity has mean 2. What's the most the chance it reaches 10 can be, knowing nothing else?

Check

Knowing only the mean and standard deviation, what is the largest possible chance of landing 2 or more standard deviations from the mean, in either direction?

Check

What does Chernoff's bound give for the chance a Gaussian lands at least 3 standard deviations above its mean?

Check

You estimate a probability by the fraction of successes in n independent trials.

(a)

By Hoeffding's bound, how many trials guarantee an error under 0.01 with probability at least 1−0.01?

(b)

How many for half that error?

Check

For the average of n = 100 Bernoulli trials with p = 0.1, compute the exact chance P(|X¯−p|≥ε) for e = 0.05 from the binomial distribution (sum the probabilities of the counts k with |k/n−p|≥ε, using math.comb or logs to avoid overflow). Set exact, cheb to Chebyshev's bound p(1−p)/(nε2) (capped at 1), and hoeff to Hoeffding's 2e−2nε2 (capped at 1).

Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.

Check

Derive Chernoff's bound for a Gaussian with mean 0 and standard deviation σ (written sg), whose M(s)=eσ2s2/2.

Step 1

What is ln⁡(e−saM(s))?

Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.

Check

You know a random variable's mean and variance but nothing about the shape of its distribution. Which tail bound can you use?

Explain why

Why is Chebyshev's bound so much looser than the truth for a Gaussian, and why can't it be made tighter without more information?

Practice

Keep practicing

7 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.