NeuroGenesys.
Probability & InferenceAcademy • Foundations • Lesson 3 of 4

Expectation, variance and why averages work

7 min read • By Will Schulz • NeuroGenesys AI Academy

How many test questions do you need before a model's benchmark score means anything? Why does a minibatch of 512 examples give a usable gradient for a dataset of billions? Both questions have the same answer: averages of independent quantities concentrate around their expectation, at a rate you can calculate.

Expectation and variance

A random variable XX attaches a number to each outcome. Its expectation is the probability-weighted average of its values:

E[X]=∑xx P(X=x)(or ∫x p(x) dx for continuous X).\mathbb{E}[X] = \sum_x x\,P(X = x) \quad \text{(or } \textstyle\int x\,p(x)\,dx \text{ for continuous } X\text{)}.

For a single test question scored 1 if correct and 0 if not, E[X]=P(correct)=p\mathbb{E}[X] = P(\text{correct}) = p. Expectation is linear: E[aX+bY]=a E[X]+b E[Y]\mathbb{E}[aX + bY] = a\,\mathbb{E}[X] + b\,\mathbb{E}[Y] for any X,YX, Y, dependent or not. That property alone makes most calculations tractable.

Variance measures spread around the mean:

Var⁡(X)=E[(X−E[X])2]=E[X2]−E[X]2,\operatorname{Var}(X) = \mathbb{E}\big[(X - \mathbb{E}[X])^2\big] = \mathbb{E}[X^2] - \mathbb{E}[X]^2,

and the standard deviation σ=Var⁡(X)\sigma = \sqrt{\operatorname{Var}(X)} is in the same units as XX. For the 0/1 score, E[X2]=p\mathbb{E}[X^2] = p, so Var⁡(X)=p(1−p)\operatorname{Var}(X) = p(1-p), largest at p=0.5p = 0.5.

Variance is not linear, but it has one crucial property. Scaling gives Var⁡(aX)=a2Var⁡(X)\operatorname{Var}(aX) = a^2 \operatorname{Var}(X), and if XX and YY are independent (more generally, uncorrelated),

Var⁡(X+Y)=Var⁡(X)+Var⁡(Y).\operatorname{Var}(X + Y) = \operatorname{Var}(X) + \operatorname{Var}(Y).

Variances add; standard deviations do not.

The average of nn samples

Let X1,…,XnX_1, \dots, X_n be independent with mean μ\mu and variance σ2\sigma^2, and let Xˉ=1n∑iXi\bar X = \frac{1}{n}\sum_i X_i. By linearity E[Xˉ]=μ\mathbb{E}[\bar X] = \mu. By additivity and scaling,

Var⁡(Xˉ)=1n2⋅nσ2=σ2n,sd⁡(Xˉ)=σn.\operatorname{Var}(\bar X) = \frac{1}{n^2} \cdot n\sigma^2 = \frac{\sigma^2}{n}, \qquad \operatorname{sd}(\bar X) = \frac{\sigma}{\sqrt n}.

This 1/n1/\sqrt n law is the reason averages work, and also the reason they work slowly: quadrupling the sample halves the error.

That the average converges to μ\mu is the law of large numbers. Jacob Bernoulli proved the first version, for the frequency of successes in repeated trials, in Ars Conjectandi, published in 1713, eight years after his death.[1] Chebyshev's 1867 paper gave the inequality that now provides a two-line proof:[2]

P(∣X−μ∣≥kσ)≤1k2.P\big(|X - \mu| \ge k\sigma\big) \le \frac{1}{k^2}.

Applied to Xˉ\bar X, whose standard deviation is σ/n\sigma/\sqrt n, the probability of any fixed deviation shrinks to zero as nn grows.

Chebyshev's bound uses only the variance, so it is loose. If each XiX_i lies in [0,1][0, 1], Hoeffding's inequality (1963) gives an exponentially small tail:[3]

P(∣Xˉ−μ∣≥t)≤2exp⁡(−2nt2).P\big(|\bar X - \mu| \ge t\big) \le 2\exp(-2nt^2).

The central limit theorem says more: for large nn, Xˉ\bar X is approximately normal with mean μ\mu and standard deviation σ/n\sigma/\sqrt n, whatever the shape of the individual XiX_i, provided their variance is finite.

Worked example: how big must a benchmark be?

You want to estimate a model's accuracy to within ±3\pm 3 percentage points with 95% confidence. Each question is a 0/1 variable with variance p(1−p)≤1/4p(1-p) \le 1/4. The three tools give three answers:

MethodRequirementQuestions needed
Chebyshev1/4n(0.03)2≤0.05\frac{1/4}{n(0.03)^2} \le 0.05n≥5,556n \ge 5{,}556
Hoeffding2e−2n(0.03)2≤0.052e^{-2n(0.03)^2} \le 0.05n≥ln⁡402(0.03)2≈2,050n \ge \frac{\ln 40}{2(0.03)^2} \approx 2{,}050
Normal approximation1.96⋅0.5n≤0.031.96 \cdot \frac{0.5}{\sqrt n} \le 0.03n≥1,068n \ge 1{,}068

Chebyshev and Hoeffding are guarantees; the normal approximation is an estimate that is accurate for sample sizes like these. All three make the same practical point: a few hundred questions cannot resolve differences of a couple of points. On a 500-question benchmark with accuracy near 70%, the standard error is 0.7×0.3/500≈0.020\sqrt{0.7 \times 0.3 / 500} \approx 0.020, so the 95% interval is roughly ±4\pm 4 points. Two models 2 points apart on such a benchmark are not distinguishable from that result alone. The reading AI results lesson returns to this.

Check your understanding

A model scores 82% on a 200-question benchmark. Roughly what is the standard error of that estimate, and the approximate 95% interval?

Show answer +

0.82×0.18/200=0.000738≈0.027\sqrt{0.82 \times 0.18 / 200} = \sqrt{0.000738} \approx 0.027. The 95% interval is about 0.82±1.96×0.0270.82 \pm 1.96 \times 0.027, roughly 77%77\% to 87%87\%, assuming questions behave like independent draws.

Where concentration shows up in deep learning

Minibatch gradients. The full training loss is an average over examples, so its gradient is an average of per-example gradients. A gradient computed on a random minibatch of BB examples is an unbiased estimate of the full gradient, with noise that shrinks as 1/B1/\sqrt B. Robbins and Monro's 1951 stochastic approximation method established that iterating with noisy but unbiased estimates, under suitable step-size conditions, still converges.[4] Stochastic gradient descent is that idea at scale (see Stochastic optimization).

Scaling in attention. A transformer compares a query qq and key kk by their dot product, q⋅k=∑i=1dqikiq \cdot k = \sum_{i=1}^{d} q_i k_i. If the components are independent with mean 0 and variance 1, each term qikiq_i k_i has mean 0 and variance 1, so by additivity the sum has variance dd and standard deviation d\sqrt d. Vaswani and colleagues used this argument to justify dividing scores by dk\sqrt{d_k}: without it, large dot products push the softmax into regions where its gradients are very small.[5]

Initialisation. The same additivity governs signals passing through a layer: each output is a sum over nn inputs, so its variance grows with nn unless the weights' variance shrinks as 1/n1/n. Glorot and Bengio's 2010 analysis of activation and gradient variances across layers led to the widely used initialisation that scales weight variance by layer width.[6]

Check your understanding

Query and key vectors have d=64d = 64 independent components, each with mean 0 and variance 1. What is the standard deviation of q⋅kq \cdot k, and of the scaled score q⋅k/64q \cdot k / \sqrt{64}?

Show answer +

Var⁡(q⋅k)=64\operatorname{Var}(q \cdot k) = 64, so the standard deviation is 8. Dividing by 64=8\sqrt{64} = 8 gives standard deviation 1, independent of dd.

When averages fail

The guarantees above rest on two assumptions, and both fail in practice.

Independence. If benchmark questions come in clusters of near-duplicates, or a model's errors are correlated across items, the effective sample size is smaller than nn and the true error bars are wider than σ/n\sigma/\sqrt n.

Finite variance and light tails. The law of large numbers needs a finite mean, and the σ/n\sigma/\sqrt n rate needs finite variance. The average of nn independent standard Cauchy variables is itself standard Cauchy: it does not concentrate at all, however large nn is. Less extreme heavy tails converge, but the normal approximation then badly misjudges rare events. The lab's Thurstone bounds Best-of-N applies exactly this caution to verifier scores. With Gaussian score noise, the chance a wrong candidate outscores a right one is Φ(−gap/(σ2))\Phi(-\text{gap}/(\sigma\sqrt 2)), where the 2\sqrt 2 comes from adding the variances of two independent scores. With Cauchy noise the Gaussian formula under-predicts that rate by more than an order of magnitude in the paper's tests, so the paper recommends checking the tail (for instance, with excess kurtosis) before trusting any Gaussian fit.[7]

Key takeaways

  • Expectation is linear; variance adds over independent terms. Together they give sd⁡(Xˉ)=σ/n\operatorname{sd}(\bar X) = \sigma/\sqrt n, the 1/n1/\sqrt n law behind every error bar.
  • Chebyshev (variance only) and Hoeffding (bounded variables) turn this into guarantees; the central limit theorem gives the usual normal-approximation intervals.
  • A few hundred evaluation items give error bars of several percentage points. Small benchmark gaps are often noise.
  • Minibatch SGD, the 1/dk1/\sqrt{d_k} in attention, and width-scaled initialisation are all applications of variance additivity.
  • Correlated samples and heavy tails break these guarantees; check both before trusting an average.

Sources

  1. E. Seneta (2013). "A Tricentenary History of the Law of Large Numbers." Bernoulli 19(4): 1088–1121. https://arxiv.org/abs/1309.6488 ↩

  2. P. L. Chebyshev (1867). "Des valeurs moyennes." Journal de Mathématiques Pures et Appliquées, 2nd series, 12: 177–184. https://numdam.org/item/JMPA_1867_2_12__177_0/ ↩

  3. W. Hoeffding (1963). "Probability Inequalities for Sums of Bounded Random Variables." Journal of the American Statistical Association 58(301): 13–30. https://doi.org/10.1080/01621459.1963.10500830 ↩

  4. H. Robbins and S. Monro (1951). "A Stochastic Approximation Method." Annals of Mathematical Statistics 22(3): 400–407. https://doi.org/10.1214/aoms/1177729586 ↩

  5. A. Vaswani et al. (2017). "Attention Is All You Need." NeurIPS 2017. arXiv:1706.03762. https://arxiv.org/abs/1706.03762 ↩

  6. X. Glorot and Y. Bengio (2010). "Understanding the difficulty of training deep feedforward neural networks." AISTATS 2010, PMLR 9: 249–256. https://proceedings.mlr.press/v9/glorot10a ↩

  7. NeuroGenesys (2026). "Thurstone bounds Best-of-N: a 1927 identity, calibrated for modern verifiers." /research/thurstone-bounds-best-of-n ↩

Leadership

A word from the founder — on why the brain is the blueprint, and why the next decade of intelligence will be built here.

"The brain is the universe's only proof that general intelligence is possible. We treat it as the blueprint."

From cortical interfaces to photonic silicon, every program at NeuroGenesys exists to answer one question: how does intelligence arise — and how do we build it safely.

Will Schulz

Will Schulz

Founder, NeuroGenesys • AW3 Technology