The population is G = (1 − ε) Bernoulli(q) + ε δa: most observations are 0 or 1, and a fraction ε equals a large value a. Its mean is μ = (1 − ε)q + εa. When ε is small the sample usually contains no value a, so X̄ ± zα/2 S/√n sits near q and misses μ. For each fixed G the coverage still tends to 1 − α; but a sequence Gn with εn = n−3/2 and an = n2 drives it to 0, so the interval is not uniform (Exercise 1.5). Intervals from Hoeffding's and Bernstein's inequalities, which use the known bound B = max(1, a), always cover. Coverages are exact sums over the trinomial law.
α = 0.05 and S2 has divisor n, as in the exercise. Hoeffding's interval has half-width B√(log(2/α)/(2n)); Bernstein's solves 2exp(−t2/(2(nσ2 + Bt/3))) = α, with σ2 = B2/4 (all that the bound B implies) or the true variance of G. The curves use 25 values of n from 10 to 398.
code/ch01_introduction.py (three_point_coverage, bernstein_halfwidth, hoeffding_halfwidth).