Why Random Answers Can Still Be Reliable
Imagine estimating the fraction of red marbles in a huge, well-mixed jar by drawing a few marbles. One draw can mislead, but repeated independent draws make a large error less likely. Streaming sketches use a related idea: controlled randomness saves space, while a probability statement limits how often the answer can be far from its target. The statement needs a target, an error threshold, a failure probability, and assumptions about how randomness enters.
For a tiny example, let $X$ be $1$ for red and $0$ otherwise. If red marbles make up half the jar, $\mathbb E[X]=1/2$. Three draws $1,0,1$ give sample average $2/3$; that is a possible observation, not a contradiction of the expected value. Expectation is the average over possible repetitions, variance measures spread around that average, and a tail probability asks how often a deviation crosses a stated threshold. Confidence amplification combines several independent attempts to reduce the chance of a bad final answer. A bound on expectation alone never says every run is close. This chapter builds on the preceding page's fixed-input randomized guarantee: we now ask which mathematical tools justify its $\varepsilon$ and $\delta$.
A random estimate can be trustworthy when its deviation probability is bounded under explicit assumptions. “Unbiased” means correct on average over the algorithm's randomness; it does not by itself guarantee a small error in any one run.
| Term | Intuitive meaning and exact example | Non-example or required assumption | Question answered |
|---|---|---|---|
| Indicator | $X=1$ if a draw is red, $0$ otherwise | A count of seven is not an indicator | How do we encode an event numerically? |
| Expectation | For red probability $p$, $\mathbb E[X]=p$ | A realized $X=1$ need not equal $p$ | Where is the average centered? |
| Variance | $\operatorname{Var}(X)=p(1-p)$ for a Bernoulli draw | Zero bias does not imply zero variance | How much does the output fluctuate? |
| Tail event | $\lvert\bar X-p\rvert\ge t$ | A statement without a threshold has no tail event | How often is the error large? |
| Failure budget | $\Pr(\text{bad estimate})\le\delta$ for fixed input | It does not automatically cover all adaptive queries | What risk does this claim allow? |
| Amplification | Median of independent attempts rejects a minority of bad outputs | Repeating the same fixed random seed need not help | How can risk be reduced? |
Why Random Answers Can Still Be Reliable
Given: two independent fair draws, encoded red $1$, blue $0$. List outcomes $(0,0),(0,1),(1,0),(1,1)$, each with probability $1/4$. The sample averages are $0,1/2,1/2,1$. Checkpoints: their mean is $1/2$; the estimate differs from $1/2$ by at least $1/2$ in two of four outcomes, so that tail probability is $1/2$. Expected result: unbiased does not mean usually exact with only two draws. Reflection: what would fail if both “draws” merely copied one earlier result?
Expectation, Variance and Indicator Variables
Let $X$ be a real-valued random variable with finite expectation $\mu=\mathbb E[X]$. Its variance, when finite, is $\sigma^2=\mathbb E[(X-\mu)^2]$. For any event $A$, the indicator $I_A$ equals $1$ on $A$ and $0$ otherwise, so $\mathbb E[I_A]=\Pr(A)$. Linearity gives $\mathbb E[\sum_i X_i]=\sum_i\mathbb E[X_i]$ even for dependent variables. Variances add as $\operatorname{Var}(\sum_i X_i)=\sum_i\operatorname{Var}(X_i)$ when variables are pairwise uncorrelated; independence is a sufficient, stronger condition. Without it, covariance terms remain.
An estimator $\widehat\theta$ is unbiased for a target $\theta$ if $\mathbb E[\widehat\theta]=\theta$. Its bias is $b=\mathbb E[\widehat\theta]-\theta$. The identity $\mathbb E[(\widehat\theta-\theta)^2]=\operatorname{Var}(\widehat\theta)+b^2$ separates spread from systematic error whenever the second moment exists. For $n$ independent Bernoulli draws with mean $p$, $\bar X=\sum_i X_i/n$ has mean $p$ and variance $p(1-p)/n\le1/(4n)$. If the draws share one random outcome, the sample average remains unbiased but its variance does not shrink with $n$.
A moment assumption is a statement such as finite mean, finite variance, or a bound on exponential moments. Higher-quality tails need stronger structure: a nonnegative random variable permits Markov's inequality; finite variance permits Chebyshev's; independent bounded summands permit Hoeffding's. Independent Bernoulli indicators permit a familiar Chernoff bound, and independent bounded summands plus their variance permit Bernstein's. Dependence can be treated with martingale differences, but only after specifying a filtration and conditional assumptions. The probability is over the estimator's randomness for a fixed input; a guarantee against an adaptive stream needs its own theorem.
flowchart TD
I["Indicator events"] --> E["Expectation by linearity"]
E --> B["Bias and target"]
E --> V["Variance with covariance accounted for"]
V --> C{"Available assumptions"}
C -->|Finite variance| W["Chebyshev: polynomial tail"]
C -->|Independent bounded terms| H["Hoeffding: exponential tail"]
C -->|Martingale differences| M["Conditional tail theorem"]
W --> A["Repetition plus median"]
H --> A
classDef navy fill:#17365D,color:#fff,stroke:#17365D;
classDef teal fill:#147D84,color:#fff,stroke:#147D84;
classDef crimson fill:#C6284D,color:#fff,stroke:#C6284D;
classDef purple fill:#6C3BAA,color:#fff,stroke:#6C3BAA;
class I,E,B navy; class V,C purple; class W,H,A teal; class M crimson;
| Statement | Exact scope | Broken assumption and counterexample | Consequence |
|---|---|---|---|
| Indicator mean | $\mathbb E[I_A]=\Pr(A)$ for any event $A$ | A variable taking values other than 0 and 1 is not $I_A$ | Converts event counts into sums |
| Linearity | $\mathbb E[\sum_iX_i]=\sum_i\mathbb E[X_i]$ when expectations exist | Expectation can be undefined for a heavy-tailed variable | Independence is not needed for the equality |
| Variance addition | Pairwise zero covariances imply variance of sum equals sum of variances | Let every $X_i$ equal one shared Bernoulli variable | Correlation can eliminate averaging's benefit |
| Unbiasedness | $\mathbb E[\widehat\theta]=\theta$ | Output $0$ or $2\theta$ equally often | A single run may have large error |
| Hoeffding for a mean | Independent $X_i\in[0,1]$ imply $\Pr(\lvert\bar X-\mathbb E\bar X\rvert\ge t)\le2e^{-2nt^2}$ | Shared draw repeated $n$ times | Cannot infer exponential shrinkage from boundedness alone |
| Martingale route | Bounded martingale differences admit Azuma–Hoeffding | A drift with nonzero conditional mean is not a martingale difference | Dependence needs conditional structure |
Linearity of expectation tolerates dependence; variance reduction and common exponential tail bounds need stronger assumptions. For independent Bernoulli trials, $\operatorname{Var}(\bar X)=p(1-p)/n$; replacing independence by identical marginals alone does not preserve this identity.
From Weak Moment Bounds to Exponential Tails
Start with little information. If $Y\ge0$ and $a>0$, then $Y\ge aI_{\{Y\ge a\}}$, hence $\mathbb E[Y]\ge a\Pr(Y\ge a)$. Thus Markov gives $\Pr(Y\ge a)\le\mathbb E[Y]/a$. Apply it to $Y=(X-\mu)^2$: if $X$ has finite variance, Chebyshev gives $\Pr(\lvert X-\mu\rvert\ge t)\le\sigma^2/t^2$. For an average of $n$ independent variables with common variance $\sigma^2$, this becomes at most $\sigma^2/(nt^2)$. Each step exposes an assumption: nonnegativity for Markov's chosen $Y$, finite second moment for Chebyshev, and variance addition for the average.
Stronger structure yields stronger tails. For independent $X_i\in[0,1]$, Hoeffding bounds the sample mean: $\Pr(\lvert\bar X-\mathbb E\bar X\rvert\ge t)\le2\exp(-2nt^2)$. Unlike Chebyshev's $1/n$ at fixed $t$, its bound decreases exponentially in $n$. For independent Bernoulli variables with sum $S$ and mean $\mu>0$, one Chernoff form for $0<\eta<1$ is $\Pr(S\le(1-\eta)\mu)\le\exp(-\eta^2\mu/2)$; another, for $\eta>0$, is $\Pr(S\ge(1+\eta)\mu)\le\left(e^{\eta}/(1+\eta)^{1+\eta}\right)^\mu$. Bernstein incorporates variance: for independent centered variables $\lvert X_i\rvert\le M$ and $v=\sum_i\mathbb E[X_i^2]$, $\Pr(\sum_iX_i\ge t)\le\exp(-t^2/[2(v+Mt/3)])$. These are different tools with different premises, not interchangeable names for “high probability.” Bounded martingale differences have Azuma–Hoeffding bounds; with a conditional variance process, Freedman's inequality may be useful. Neither permits arbitrary dependence or adversarial choices after seeing secret randomness without further analysis.
Amplify a weak estimator. Suppose one independent run lands within $\varepsilon$ of the target with probability at least $3/4$. Run it $k$ times with independent randomness and take the median. The median is bad only if at least half of the runs are bad. Hoeffding on their failure indicators bounds that event by $\exp(-k/8)$, so $k\ge8\ln(1/\delta)$ suffices for failure at most $\delta$ (round up to an integer). For finite-variance data, the median of means makes this concrete: split independent observations into $k$ disjoint blocks of size $b\ge4\sigma^2/\varepsilon^2$, average each block, then take their median. Chebyshev makes each block fail with probability at most $1/4$, after which the median bound applies. Bias needs separate attention: if every run is centered on the wrong value, repetition concentrates around that wrong value.
flowchart TD
A["Nonnegative quantity"] --> B["Markov via threshold indicator"]
B --> C["Square deviation, finite variance"]
C --> D["Chebyshev: weak single-run bound"]
D --> E["Independent repetitions"]
E --> F["Median fails if half fail"]
F --> G["Exponential failure bound"]
C --> H{"Independent bounded terms?"}
H -->|Yes| I["Hoeffding or Chernoff"]
H -->|No| J["Check covariance or martingale assumptions"]
I --> G
classDef navy fill:#17365D,color:#fff,stroke:#17365D;
classDef teal fill:#147D84,color:#fff,stroke:#147D84;
classDef crimson fill:#C6284D,color:#fff,stroke:#C6284D;
classDef purple fill:#6C3BAA,color:#fff,stroke:#6C3BAA;
class A,B,C navy; class D,E,F,G,I teal; class J crimson; class H purple;
From Weak Moment Bounds to Exponential Tails
Given: independent Bernoulli draws with $p=1/2$, $n=100$, and tolerance $t=0.1$. First derive $\operatorname{Var}(\bar X)=p(1-p)/n=0.0025$. Chebyshev then gives $\Pr(\lvert\bar X-0.5\rvert\ge0.1)\le0.25$. Hoeffding gives $2e^{-2(100)(0.1)^2}=2e^{-2}\approx0.271$, a valid but slightly weaker numerical bound here; compare the bound, not an unobserved true failure rate. At $n=400$, Chebyshev gives $0.0625$ and Hoeffding gives $2e^{-8}\approx0.000671$, revealing the exponential advantage. Variation: set all $400$ draws equal to one fair Bernoulli variable. Then $\bar X$ equals $0$ or $1$, so the actual probability of deviation at least $0.1$ is $1$; independence was essential to both displayed sample-mean calculations.
| Tool | Bound or conclusion | Assumptions and useful regime | Representative failure |
|---|---|---|---|
| Markov | $\Pr(Y\ge a)\le\mathbb E[Y]/a$ | $Y\ge0$, $a>0$; only first moment | Applying it directly to signed $Y$ |
| Chebyshev | $\Pr(\lvert X-\mu\rvert\ge t)\le\sigma^2/t^2$ | Finite variance; polynomial tail, often loose | Assuming a variance from independent draws when samples are copies |
| Hoeffding | For independent $X_i\in[0,1]$, mean tail at most $2e^{-2nt^2}$ | Bounded independent draws; exponential in $n$ | Shared randomness between draws |
| Chernoff | Bernoulli sum lower tail at most $e^{-\eta^2\mu/2}$ for $0<\eta<1$ | Independent indicators; multiplicative deviation | Treating a correlated count as independent trials |
| Bernstein | One-sided tail $e^{-t^2/[2(v+Mt/3)]}$ | Independent centered terms bounded by $M$ with variance sum $v$ | Unknown heavy-tailed increments |
| Median of means | Failure at most $e^{-k/8}$ for block size $b\ge4\sigma^2/\varepsilon^2$ | Independent observations, finite variance, independent blocks | Overlapping blocks or persistent bias |
One Alert, Ten Thousand Services
Approachable quality check. A teacher samples independent answers from a large shuffled stack, coding correct as $1$. If $n=50$ of $100$ sampled answers are correct, the estimate is $0.5$; the statement $\Pr(\lvert\bar X-p\rvert\ge0.2)\le2e^{-2(50)(0.2)^2}=2e^{-4}\approx0.0366$ follows under independent sampling with replacement. Without replacement, the draws are dependent; this particular theorem is no longer the direct justification, even though another suitable bound may exist. The model describes repeated randomized selection, not a guarantee that the observed fraction equals the population fraction.
Production telemetry. Suppose a platform monitors $10{,}000$ services, producing one fixed accuracy query per service in a reporting interval. To make the chance of any estimate exceeding tolerance at most $0.01$, the union bound suffices with per-query $\delta=10^{-6}$. If each estimate is a mean of independent bounded observations and needs additive tolerance $0.1$, Hoeffding asks for $n\ge\ln(2/\delta)/(2(0.1)^2)\approx725.43$, so $726$ samples per service suffice under the model. This is a conservative design calculation, not proof that those samples are feasible or that alert thresholds have a 1% false-alarm rate. Selection bias, missing events, and cross-service correlations affect the target or assumptions; the union bound itself requires no independence between services.
Misleading security case. An operator repeatedly inspects noisy dashboard outputs and chooses the next service and time window based on them. A guarantee proved for each fixed query does not automatically cover the selected query: its choice depends on previous randomized answers. Similarly, a sampling gateway that drops overloaded events changes the population represented by the observations. If an attacker sees a sketch's random hash seed, a theorem assuming a fixed stream independent of private coins may fail. The practical conclusion changes from “apply the same $\delta$” to “verify a simultaneous or adaptive guarantee, plus an honest data-collection model.”
One Alert, Ten Thousand Services: Probability, Concentration & Confidence Amplification
Inputs: a quality team samples $50$ independent responses with replacement, $30$ correct, and wants tolerance $0.2$ for the population accuracy $p$. Model selection: code correct as a Bernoulli indicator, estimate $\bar X=30/50=0.6$, and apply Hoeffding to an absolute deviation, not to the event “the service is good.” Calculation: $2e^{-2(50)(0.2)^2}=2e^{-4}\approx0.0366$. Expected interpretation: with this sampling procedure, the chance that the estimate differs from the fixed population share by at least $0.2$ is at most $0.0366$; this does not prove $p$ lies in a specific interval with certainty. Success criterion: provide the target, the sample, the event being bounded, and the assumption that each draw follows the same distribution independently. Change one assumption: if only easy responses are sampled, identify selection bias before quoting the bound.
One Alert, Ten Thousand Services: Probability, Concentration & Confidence Amplification
Workload: $10{,}000$ fixed service queries per interval, overall estimation-failure budget $0.01$, additive tolerance $0.1$, event ingestion subject to bursts. Contract: per query $\delta=10^{-6}$ by union bound; for independent bounded observations use $n=726$ as a sufficient Hoeffding sample size per service. That is up to $7.26$ million sampled observations across services per interval. Evidence to collect: effective sample counts, sampling probabilities, dropped-event patterns, shared random seeds, latency and memory costs, and a replay comparison with exact offline answers. Risk: threshold-based alerting adds decision error beyond the estimate's deviation event; a service with true value near the threshold may legitimately flip classification. Written decision: state whether the system can afford the sample and query budget, how it handles sparse services, whether queries are fixed or adaptively chosen, and which alert decisions require exact follow-up. Acceptance requires a traceable $\varepsilon$–$\delta$ calculation and a measured data-collection audit.
Build and Audit a Confidence Budget
Start with the event whose probability you want to limit. Choose a bound whose assumptions fit the estimator, then allocate failure probability across runs, services, and time windows. The exercises progress from identifying a missing premise to reviewing a realistic contract; each answer should say exactly what follows and what still needs evidence.
Practice: Build and Audit a Confidence Budget
1. Define (2 points). For $X\in\{0,1\}$ with $\Pr(X=1)=0.3$, give $\mathbb E[X]$ and $\operatorname{Var}(X)$. Expected: $0.3$ and $0.21$. Explain why seeing $X=1$ does not contradict the mean.
2. Derive (2 points). An unbiased estimator has variance $9$; find Chebyshev's bound on absolute error at least $6$. Hint: apply Markov to squared error. Expected: $9/36=0.25$. If its bias is $2$, unbiased Chebyshev centered at the target no longer applies directly; state the center and use the triangle inequality if claiming a target-error bound.
3. Counterexample (2 points). Compare $n$ independent fair indicators with $n$ copies of one fair indicator. Expected: both means have expectation $1/2$; their variances are respectively $1/(4n)$ and $1/4$. Identify exactly where a Hoeffding calculation for the copied sequence breaks.
4. Budget (2 points). For $200$ fixed queries and total failure at most $0.02$, allocate equal per-query budgets. Expected: $\delta=0.0001$ per query is sufficient by union bound, even when query failures are dependent. Explain why querying until an attractive answer appears requires another argument.
5. Extension and audit (2 points). An estimator has finite variance $\sigma^2=16$ and independent observations; target error $\varepsilon=2$, final failure $\delta=0.01$. Use median of means with $b=\lceil4\sigma^2/\varepsilon^2\rceil=16$ per block and $k=\lceil8\ln(100)\rceil=37$ blocks, for $592$ observations. Check that Chebyshev makes each block failure at most $1/4$, then that $e^{-37/8}<0.01$. Debug: overlapping blocks, underestimated variance, or a biased sampling frame break different steps. Artifact: a short proof and a table of input assumptions, observed evidence, and failure modes. Stretch: compare total sample cost with a bounded-data Hoeffding route. Full credit names the probability space, the target, and every independence assumption.
Audit the target and sampling process, bias, moments or bounds, independence or conditional structure, the exact deviation event, the number of queries, and who can adapt to revealed outputs before spending a confidence budget. The next topics use this toolkit to justify hashing and streaming estimators; revisit the preceding chapter's fixed-input and simultaneous-query distinctions whenever a new guarantee is claimed.
Next in the Series
In Hashing, Independence & Pseudorandomness, we'll explore Use just enough randomness for fast, reproducible sketches..