Track 0 · Math Foundations · 06/10

통계와 추정Statistics and estimation

추정량의 편향·분산·MSE, MLE(Bernoulli·Gaussian)와 Fisher 정보, 중심극한정리와 신뢰구간(Wald가 어디서 무너지는지), Hoeffding과 union bound, 부트스트랩, importance sampling과 ESS(시퀀스 길이에 따른 붕괴), control variate로서의 baseline, 그리고 모델 평가의 통계 — pass@k 불편 추정량, 벤치마크 점수의 분산, 두 모델을 가르는 데 필요한 문항 수.Bias, variance and MSE of estimators; MLE (Bernoulli, Gaussian) and Fisher information; the central limit theorem and confidence intervals (and where Wald breaks); Hoeffding and the union bound; the bootstrap; importance sampling and the effective sample size (and its collapse with sequence length); baselines as control variates; and the statistics of evaluation — the unbiased pass@k estimator, the variance of benchmark scores, and how many questions it takes to separate two models.

50 분min statistics · estimator · bias · variance · MLE · fisher information · CLT · confidence interval · bootstrap · importance sampling · ESS · control variate · pass@k · evaluation 먼저 볼 것:Before this: 확률Probability

Probability goes from a model to data; statistics goes back. On this site that return trip happens constantly: a KL estimator from sampled tokens, a policy gradient from a batch of rollouts, an off-policy correction from importance weights, and every benchmark number in every report. This lesson collects the tools to judge such numbers: what makes an estimator good, how big its error is, how to put an interval around it, and how to make the error smaller without more samples.

Estimators: bias, variance, MSE

An estimator θ^\hat\theta is a function of random data, so it is itself a random variable with a sampling distribution. Its error decomposes exactly:

MSE(θ^)=E[(θ^−θ)2]=(Eθ^−θ)2⏟bias2+E[(θ^−Eθ^)2]⏟variance,\mathrm{MSE}(\hat\theta) = \mathbb{E}\big[(\hat\theta - \theta)^2\big] = \underbrace{\big(\mathbb{E}\hat\theta - \theta\big)^2}_{\text{bias}^2} + \underbrace{\mathbb{E}\big[(\hat\theta - \mathbb{E}\hat\theta)^2\big]}_{\text{variance}},

because the cross term 2(Eθ^−θ) E[θ^−Eθ^]2(\mathbb{E}\hat\theta - \theta)\,\mathbb{E}[\hat\theta - \mathbb{E}\hat\theta] is zero. Unbiased means the first term vanishes; consistent means θ^→θ\hat\theta \to \theta as the sample grows. Neither is the same as accurate.

Worked example: the sample variance. With xix_i iid, mean μ\mu, variance σ2\sigma^2, write xi−xˉ=(xi−μ)−(xˉ−μ)x_i - \bar x = (x_i - \mu) - (\bar x - \mu) and sum the squares:

∑i(xi−xˉ)2=∑i(xi−μ)2−n(xˉ−μ)2  ⇒  E∑i(xi−xˉ)2=nσ2−n⋅σ2n=(n−1)σ2.\sum_i (x_i - \bar x)^2 = \sum_i (x_i - \mu)^2 - n(\bar x - \mu)^2 \;\Rightarrow\; \mathbb{E}\sum_i (x_i - \bar x)^2 = n\sigma^2 - n\cdot\frac{\sigma^2}{n} = (n-1)\sigma^2 .

One degree of freedom is spent estimating the mean, so dividing by n−1n-1 is unbiased and dividing by nn is biased low by σ2/n\sigma^2/n. For Gaussian data ∑(xi−xˉ)2/σ2∼χn−12\sum(x_i - \bar x)^2/\sigma^2 \sim \chi^2_{n-1} (mean n−1n-1, variance 2(n−1)2(n-1)), so σ^D2=∑(xi−xˉ)2/D\hat\sigma^2_D = \sum(x_i - \bar x)^2/D has

MSE(D)=σ4 (n−1−D)2+2(n−1)D2,\mathrm{MSE}(D) = \sigma^4\,\frac{(n-1-D)^2 + 2(n-1)}{D^2},

minimised at D=n+1D = n+1: shrinking toward zero trades a little bias for a larger cut in variance.

확률은 모델에서 데이터로 가고, 통계는 데이터에서 모델로 돌아온다. 이 사이트에서는 그 귀로가 끊임없이 일어난다. 샘플한 토큰으로 KL을 추정하고, rollout 배치로 정책 경사를 추정하고, importance weight로 off-policy를 보정하고, 모든 보고서의 모든 벤치마크 숫자가 그렇다. 이 레슨은 그런 숫자를 판단하는 도구를 모은다. 좋은 추정량은 무엇인지, 그 오차는 얼마나 큰지, 구간을 어떻게 씌우는지, 샘플을 늘리지 않고 오차를 어떻게 줄이는지.

추정량: 편향, 분산, MSE

추정량 θ^\hat\theta는 무작위 데이터의 함수이므로 그 자체로 표본분포를 가진 확률변수다. 그 오차는 정확히 분해된다.

MSE(θ^)=E[(θ^−θ)2]=(Eθ^−θ)2⏟편향2+E[(θ^−Eθ^)2]⏟분산,\mathrm{MSE}(\hat\theta) = \mathbb{E}\big[(\hat\theta - \theta)^2\big] = \underbrace{\big(\mathbb{E}\hat\theta - \theta\big)^2}_{\text{편향}^2} + \underbrace{\mathbb{E}\big[(\hat\theta - \mathbb{E}\hat\theta)^2\big]}_{\text{분산}},

교차항 2(Eθ^−θ) E[θ^−Eθ^]2(\mathbb{E}\hat\theta - \theta)\,\mathbb{E}[\hat\theta - \mathbb{E}\hat\theta]가 0이기 때문이다. 불편(unbiased) 이면 첫 항이 사라지고, 일치(consistent) 이면 표본이 커질 때 θ^→θ\hat\theta \to \theta다. 둘 다 정확하다는 뜻은 아니다.

풀어 보는 예: 표본분산. xix_i가 iid, 평균 μ\mu, 분산 σ2\sigma^2이면 xi−xˉ=(xi−μ)−(xˉ−μ)x_i - \bar x = (x_i - \mu) - (\bar x - \mu)로 쓰고 제곱해 더한다.

∑i(xi−xˉ)2=∑i(xi−μ)2−n(xˉ−μ)2  ⇒  E∑i(xi−xˉ)2=nσ2−n⋅σ2n=(n−1)σ2.\sum_i (x_i - \bar x)^2 = \sum_i (x_i - \mu)^2 - n(\bar x - \mu)^2 \;\Rightarrow\; \mathbb{E}\sum_i (x_i - \bar x)^2 = n\sigma^2 - n\cdot\frac{\sigma^2}{n} = (n-1)\sigma^2 .

평균을 추정하는 데 자유도 하나를 쓰므로 n−1n-1로 나누면 불편이고, nn으로 나누면 σ2/n\sigma^2/n만큼 낮게 편향된다. Gaussian 데이터면 ∑(xi−xˉ)2/σ2∼χn−12\sum(x_i - \bar x)^2/\sigma^2 \sim \chi^2_{n-1}(평균 n−1n-1, 분산 2(n−1)2(n-1))이므로 σ^D2=∑(xi−xˉ)2/D\hat\sigma^2_D = \sum(x_i - \bar x)^2/D는

MSE(D)=σ4 (n−1−D)2+2(n−1)D2\mathrm{MSE}(D) = \sigma^4\,\frac{(n-1-D)^2 + 2(n-1)}{D^2}

이고, D=n+1D = n+1에서 최소다. 0 쪽으로 줄이면 편향이 조금 생기는 대신 분산이 더 크게 준다.

나누는 수divisor D:
평균mean – 편향bias – sd – MSE –
Draw 4000 datasets of n points from N(0, 1) and estimate σ² = 1 from each with σ̂² = Σ(xᵢ − x̄)²/D. Left: the 4000 estimates of the chosen estimator (black line = truth, coloured line = their mean). Right: exact bias² (amber) and variance (blue) for each divisor; the stack height is the MSE, dots are the simulated MSE. The unbiased n−1 is never the most accurate: dividing by n+1 shrinks the estimate, adds bias, removes more variance. Slide n up and the three converge — bias and the gap between them are O(1/n), the standard deviation is O(1/√n). N(0, 1)에서 n개짜리 데이터셋을 4000개 뽑고, 각각에서 σ̂² = Σ(xᵢ − x̄)²/D로 σ² = 1을 추정한다. 왼쪽: 고른 추정량의 추정값 4000개(검은 선 = 참값, 색 선 = 그 평균). 오른쪽: 나누는 수마다 정확한 편향²(주황)과 분산(파랑). 쌓인 높이가 MSE이고 점은 시뮬레이션 MSE다. 불편인 n−1은 결코 가장 정확하지 않다. n+1로 나누면 추정값이 줄어들어 편향이 생기지만 분산이 더 많이 줄어든다. n을 키우면 셋이 수렴한다. 편향과 셋의 차이는 O(1/n), 표준편차는 O(1/√n)이다.

The same trade appears all over post-training: the KL estimators k1k_1 (unbiased, high variance), k2k_2 (biased, low variance) and k3k_3 (unbiased, low variance near πref\pi_{\text{ref}}) in KL-regularised RL; truncated importance weights (bias for bounded variance) in off-policy mismatch; GRPO’s std normalisation and length aggregation, which change what is estimated, in sequence vs token. (The bias–variance trade-off of generalisation is the same decomposition applied to a model’s prediction at a point, with the training set as the random data.)

Maximum likelihood

Given iid data and a model pθp_\theta, the maximum likelihood estimate maximises ℓ(θ)=∑ilog⁡pθ(xi)\ell(\theta) = \sum_i \log p_\theta(x_i). Equivalently it minimises the cross-entropy from the empirical distribution to the model — the reason training an LM with next-token cross-entropy is MLE (probability and losses, language modelling), and why a reward model trained on the Bradley–Terry log-loss is an MLE (reward models).

Bernoulli. kk successes in nn trials: ℓ(p)=klog⁡p+(n−k)log⁡(1−p)\ell(p) = k\log p + (n-k)\log(1-p), so ℓ′(p)=k/p−(n−k)/(1−p)=0\ell'(p) = k/p - (n-k)/(1-p) = 0 gives p^=k/n\hat p = k/n, the accuracy.

Gaussian. ℓ(μ,σ2)=−n2log⁡(2πσ2)−12σ2∑i(xi−μ)2\ell(\mu,\sigma^2) = -\tfrac n2\log(2\pi\sigma^2) - \tfrac{1}{2\sigma^2}\sum_i(x_i-\mu)^2. Setting ∂μℓ=0\partial_\mu\ell = 0 gives μ^=xˉ\hat\mu = \bar x; setting ∂σ2ℓ=−n2σ2+12σ4∑i(xi−μ)2=0\partial_{\sigma^2}\ell = -\tfrac{n}{2\sigma^2} + \tfrac{1}{2\sigma^4}\sum_i(x_i-\mu)^2 = 0 gives σ^2=1n∑i(xi−xˉ)2\hat\sigma^2 = \tfrac1n\sum_i(x_i - \bar x)^2 — the biased, divide-by-nn estimator from the figure. MLE is not designed to be unbiased.

How accurate is it? Under regularity conditions the MLE is consistent and asymptotically normal,

θ^≈N(θ, 1n I(θ)),I(θ)=E[(∂θlog⁡pθ(x))2]=−E[∂θ2log⁡pθ(x)],\hat\theta \approx \mathcal{N}\Big(\theta,\ \frac{1}{n\,I(\theta)}\Big), \qquad I(\theta) = \mathbb{E}\big[(\partial_\theta\log p_\theta(x))^2\big] = -\mathbb{E}\big[\partial_\theta^2\log p_\theta(x)\big],

where II is the Fisher information — the expected curvature of the log-likelihood. Sharp likelihood peak, small error. For a Bernoulli −∂p2log⁡pp(x)=x/p2+(1−x)/(1−p)2-\partial_p^2\log p_p(x) = x/p^2 + (1-x)/(1-p)^2, whose expectation is I(p)=1/(p(1−p))I(p) = 1/(p(1-p)), so se(p^)=p(1−p)/n\mathrm{se}(\hat p) = \sqrt{p(1-p)/n}: the error bar of every accuracy. (The Fisher matrix is also the metric behind natural gradients and TRPO’s KL trust region, since KL(pθ∥pθ+δ)≈12δ⊤I(θ) δ\mathrm{KL}(p_\theta\|p_{\theta+\delta}) \approx \tfrac12\delta^\top I(\theta)\,\delta.)

NumPy Bias, variance and MSE; MLE and its standard error
import numpy as np
rng = np.random.default_rng(0)

# three estimators of sigma^2 = 1 from n = 5 Gaussian samples
n, M = 5, 200_000
X = rng.normal(size=(M, n))
S = ((X - X.mean(1, keepdims=True)) ** 2).sum(1)
print(f"estimating sigma^2 = 1 from n = {n} Gaussian samples")
for D, name in [(n - 1, "n-1 (unbiased)"), (n, "n   (MLE)"), (n + 1, "n+1")]:
    est = S / D
    bias, var = est.mean() - 1, est.var()
    print(f"  /{name:15s} bias {bias:+.4f}  var {var:.4f}  bias^2+var {bias**2 + var:.4f}  MSE {np.mean((est - 1)**2):.4f}")

# Bernoulli MLE p_hat = k/n; Fisher information 1/(p(1-p)) -> se = sqrt(p(1-p)/n)
p, n = 0.3, 400
p_hat = rng.binomial(n, p, size=100_000) / n
print(f"\nBernoulli MLE: mean {p_hat.mean():.4f}, sd {p_hat.std():.5f}, 1/sqrt(n I(p)) = {np.sqrt(p*(1-p)/n):.5f}")

# the log-likelihood is maximised at k/n (check on a grid)
k = 123
grid = np.linspace(0.01, 0.99, 9801)
ll = k * np.log(grid) + (n - k) * np.log(1 - grid)
print(f"argmax of the log-likelihood on a grid = {grid[np.argmax(ll)]:.4f},  k/n = {k/n:.4f}")
 

The central limit theorem and confidence intervals

For iid xix_i with mean μ\mu and finite variance σ2\sigma^2,

xˉn−μσ/n  →d  N(0,1),\frac{\bar x_n - \mu}{\sigma/\sqrt n} \;\xrightarrow{d}\; \mathcal{N}(0, 1),

whatever the distribution of xix_i. So xˉ\bar x is approximately Gaussian with standard error se=σ/n\mathrm{se} = \sigma/\sqrt n, estimated by s/ns/\sqrt n, and

xˉ±1.96 se\bar x \pm 1.96\,\mathrm{se}

is an approximate 95% confidence interval. The 95% is a property of the procedure: over repeated experiments, 95% of the intervals so constructed contain μ\mu; any single interval either does or does not. For an accuracy p^=k/n\hat p = k/n this is the Wald interval p^±1.96p^(1−p^)/n\hat p \pm 1.96\sqrt{\hat p(1-\hat p)/n}. It fails when np^n\hat p or n(1−p^)n(1-\hat p) is small — near-perfect scores on small benchmarks — because it plugs p^\hat p into the variance (zero width when p^∈{0,1}\hat p \in\{0, 1\}) and the binomial is skewed there. The Wilson interval inverts the test instead, solving ∣p^−p∣≤zp(1−p)/n|\hat p - p| \le z\sqrt{p(1-p)/n} for pp:

p^+z22n1+z2n  ±  z1+z2np^(1−p^)n+z24n2.\frac{\hat p + \frac{z^2}{2n}}{1 + \frac{z^2}{n}} \;\pm\; \frac{z}{1 + \frac{z^2}{n}}\sqrt{\frac{\hat p(1-\hat p)}{n} + \frac{z^2}{4n^2}} .

같은 trade-off가 사후학습 곳곳에 나온다. KL 정규화 RL의 KL 추정량 k1k_1(불편, 고분산), k2k_2(편향, 저분산), k3k_3(불편, πref\pi_{\text{ref}} 근처에서 저분산), off-policy 불일치의 잘린 importance weight(유계 분산을 위한 편향), 무엇을 추정하는지를 바꾸는 GRPO의 std 정규화와 길이 집계(시퀀스 vs 토큰)가 그렇다. (일반화의 bias–variance trade-off는 같은 분해를 한 점에서의 모델 예측에 적용한 것이다. 거기서는 학습 데이터가 무작위 데이터다.)

최대우도 추정

iid 데이터와 모델 pθp_\theta가 주어지면 최대우도 추정(MLE) 은 ℓ(θ)=∑ilog⁡pθ(xi)\ell(\theta) = \sum_i \log p_\theta(x_i)를 최대화한다. 동치로, 경험 분포에서 모델로의 cross-entropy를 최소화한다. 다음 토큰 cross-entropy로 LM을 학습하는 것이 곧 MLE인 이유이고(확률로 보는 손실, 언어 모델링), Bradley–Terry 로그 손실로 학습한 보상모델이 MLE인 이유다(보상모델).

Bernoulli. nn번 중 kk번 성공: ℓ(p)=klog⁡p+(n−k)log⁡(1−p)\ell(p) = k\log p + (n-k)\log(1-p)이므로 ℓ′(p)=k/p−(n−k)/(1−p)=0\ell'(p) = k/p - (n-k)/(1-p) = 0에서 p^=k/n\hat p = k/n, 곧 정확도다.

Gaussian. ℓ(μ,σ2)=−n2log⁡(2πσ2)−12σ2∑i(xi−μ)2\ell(\mu,\sigma^2) = -\tfrac n2\log(2\pi\sigma^2) - \tfrac{1}{2\sigma^2}\sum_i(x_i-\mu)^2. ∂μℓ=0\partial_\mu\ell = 0에서 μ^=xˉ\hat\mu = \bar x, ∂σ2ℓ=−n2σ2+12σ4∑i(xi−μ)2=0\partial_{\sigma^2}\ell = -\tfrac{n}{2\sigma^2} + \tfrac{1}{2\sigma^4}\sum_i(x_i-\mu)^2 = 0에서 σ^2=1n∑i(xi−xˉ)2\hat\sigma^2 = \tfrac1n\sum_i(x_i - \bar x)^2. 그림의 nn으로 나누는 편향 추정량이다. MLE는 불편이 되도록 설계된 것이 아니다.

얼마나 정확한가? 정칙 조건 아래서 MLE는 일치 추정량이고 점근적으로 정규분포를 따른다.

θ^≈N(θ, 1n I(θ)),I(θ)=E[(∂θlog⁡pθ(x))2]=−E[∂θ2log⁡pθ(x)],\hat\theta \approx \mathcal{N}\Big(\theta,\ \frac{1}{n\,I(\theta)}\Big), \qquad I(\theta) = \mathbb{E}\big[(\partial_\theta\log p_\theta(x))^2\big] = -\mathbb{E}\big[\partial_\theta^2\log p_\theta(x)\big],

II는 Fisher 정보, 로그우도의 기대 곡률이다. 우도의 봉우리가 뾰족하면 오차가 작다. Bernoulli에서 −∂p2log⁡pp(x)=x/p2+(1−x)/(1−p)2-\partial_p^2\log p_p(x) = x/p^2 + (1-x)/(1-p)^2이고 그 기댓값이 I(p)=1/(p(1−p))I(p) = 1/(p(1-p))이므로 se(p^)=p(1−p)/n\mathrm{se}(\hat p) = \sqrt{p(1-p)/n}이다. 모든 정확도의 오차 막대다. (KL(pθ∥pθ+δ)≈12δ⊤I(θ) δ\mathrm{KL}(p_\theta\|p_{\theta+\delta}) \approx \tfrac12\delta^\top I(\theta)\,\delta이므로 Fisher 행렬은 natural gradient와 TRPO KL trust region 뒤의 계량이기도 하다.)

NumPy 편향, 분산, MSE; MLE와 표준오차
import numpy as np
rng = np.random.default_rng(0)

# n = 5개 Gaussian 표본으로 sigma^2 = 1을 추정하는 세 추정량
n, M = 5, 200_000
X = rng.normal(size=(M, n))
S = ((X - X.mean(1, keepdims=True)) ** 2).sum(1)
print(f"n = {n}개 Gaussian 표본으로 sigma^2 = 1 추정")
for D, name in [(n - 1, "n-1 (불편)"), (n, "n   (MLE)"), (n + 1, "n+1")]:
    est = S / D
    bias, var = est.mean() - 1, est.var()
    print(f"  /{name:12s} 편향 {bias:+.4f}  분산 {var:.4f}  편향^2+분산 {bias**2 + var:.4f}  MSE {np.mean((est - 1)**2):.4f}")

# Bernoulli MLE p_hat = k/n; Fisher 정보 1/(p(1-p)) -> se = sqrt(p(1-p)/n)
p, n = 0.3, 400
p_hat = rng.binomial(n, p, size=100_000) / n
print(f"\nBernoulli MLE: 평균 {p_hat.mean():.4f}, 표준편차 {p_hat.std():.5f}, 1/sqrt(n I(p)) = {np.sqrt(p*(1-p)/n):.5f}")

# 로그우도는 k/n에서 최대 (격자에서 확인)
k = 123
grid = np.linspace(0.01, 0.99, 9801)
ll = k * np.log(grid) + (n - k) * np.log(1 - grid)
print(f"격자 위 로그우도의 argmax = {grid[np.argmax(ll)]:.4f},  k/n = {k/n:.4f}")
 

중심극한정리와 신뢰구간

평균 μ\mu, 유한 분산 σ2\sigma^2인 iid xix_i에 대해

xˉn−μσ/n  →d  N(0,1)\frac{\bar x_n - \mu}{\sigma/\sqrt n} \;\xrightarrow{d}\; \mathcal{N}(0, 1)

이고, xix_i의 분포가 무엇이든 그렇다. 그래서 xˉ\bar x는 표준오차 se=σ/n\mathrm{se} = \sigma/\sqrt n(추정은 s/ns/\sqrt n)인 근사 Gaussian이고,

xˉ±1.96 se\bar x \pm 1.96\,\mathrm{se}

가 근사 95% 신뢰구간이다. 95%는 절차의 성질이다. 실험을 반복하면 이렇게 만든 구간의 95%가 μ\mu를 포함한다. 구간 하나는 포함하거나 포함하지 않거나다. 정확도 p^=k/n\hat p = k/n에 대해서는 Wald 구간 p^±1.96p^(1−p^)/n\hat p \pm 1.96\sqrt{\hat p(1-\hat p)/n}이 된다. np^n\hat p나 n(1−p^)n(1-\hat p)가 작으면, 즉 작은 벤치마크에서 거의 만점이면 무너진다. 분산에 p^\hat p를 넣기 때문에(p^∈{0,1}\hat p \in\{0, 1\}이면 폭 0) 그리고 그 근처에서 이항분포가 치우쳐 있기 때문이다. Wilson 구간은 대신 검정을 뒤집어 ∣p^−p∣≤zp(1−p)/n|\hat p - p| \le z\sqrt{p(1-p)/n}을 pp에 대해 푼다.

p^+z22n1+z2n  ±  z1+z2np^(1−p^)n+z24n2.\frac{\hat p + \frac{z^2}{2n}}{1 + \frac{z^2}{n}} \;\pm\; \frac{z}{1 + \frac{z^2}{n}}\sqrt{\frac{\hat p(1-\hat p)}{n} + \frac{z^2}{4n^2}} .
95% 반폭(정규근사, 참 p)95% half-width (normal approx., true p) – 포함률coverage – 정확한 포함률(이항)exact coverage (binomial) – MDE (독립)(unpaired) – MDE (쌍)(paired) –
Each horizontal segment is one benchmark run of n questions with true accuracy p and its 95% interval; red ones miss the truth (black line). About 5% should miss. Press +5000 for a stable coverage estimate; it converges to the exact coverage Σk P(K = k)·1[p ∈ CI(k)] shown next to it (runs are exact binomial draws). Now set n ≈ 20 and p = 0.95: the Wald interval p̂ ± 1.96√(p̂(1−p̂)/n) covers far less than 95% (it collapses to zero width whenever all answers are right); Wilson comes much closer. Right: the normal-approximation half-width at the true p, 1.96√(p(1−p)/n) (whichever interval is selected), falls like 1/√n — 4× the questions for half the width — and the smallest difference between two models you can reliably detect (80% power, α = 0.05) is about 2.8× the standard error of the difference. Scoring both models on the same questions (paired) multiplies that variance by (1 − ρ), where ρ is the correlation of their per-question correctness. 가로 선분 하나가 참 정확도 p, 문항 n개짜리 벤치마크 실행 한 번과 그 95% 구간이다. 빨간 선분은 참값(검은 선)을 놓친 것이다. 약 5%가 놓쳐야 한다. +5000을 누르면 포함률 추정이 안정되고, 옆에 보이는 정확한 포함률 Σk P(K = k)·1[p ∈ CI(k)]로 수렴한다(실행은 정확한 이항 샘플이다). 이제 n ≈ 20, p = 0.95로 두면 Wald 구간 p̂ ± 1.96√(p̂(1−p̂)/n)의 포함률이 95%에 한참 못 미친다(모두 맞히면 폭이 0으로 무너진다). Wilson은 95%에 훨씬 가깝다. 오른쪽: 참 p에서의 정규근사 반폭 1.96√(p(1−p)/n)(어느 구간을 골랐든 같은 식)은 1/√n으로 줄어든다. 폭을 절반으로 줄이려면 문항이 4배 필요하다. 두 모델 사이에서 믿을 만하게 검출할 수 있는 최소 차이(검정력 80%, α = 0.05)는 차이의 표준오차의 약 2.8배다. 두 모델을 같은 문항으로 채점하면(paired) 그 분산이 (1−ρ)배가 된다.

Concentration: Hoeffding and the union bound

The CLT is asymptotic. When a guarantee must hold at a finite nn, use a concentration inequality. For independent xi∈[a,b]x_i \in [a, b], Hoeffding’s inequality gives

P(∣xˉn−μ∣≥ε)≤2exp⁡ ⁣(−2nε2(b−a)2),P\big(|\bar x_n - \mu| \ge \varepsilon\big) \le 2\exp\!\Big(-\frac{2n\varepsilon^2}{(b-a)^2}\Big),

the same ε∝1/n\varepsilon \propto 1/\sqrt n scaling as the CLT but with no approximation and no variance estimate (it uses only the range, so it is loose when the variance is small). To make KK such statements hold simultaneously, the union bound P(∪kAk)≤∑kP(Ak)P(\cup_k A_k) \le \sum_k P(A_k) multiplies the failure probability by KK, so n≥(b−a)22ε2log⁡2Kδn \ge \frac{(b-a)^2}{2\varepsilon^2}\log\frac{2K}{\delta} suffices for all KK means to be within ε\varepsilon with probability 1−δ1 - \delta. The price of KK comparisons is only log⁡K\log K. For a 0/1 accuracy, ε=3\varepsilon = 3 points, δ=0.05\delta = 0.05: one benchmark needs n≥log⁡40/(2⋅0.032)≈2,050n \ge \log 40/(2\cdot 0.03^2) \approx 2{,}050 questions (the CLT’s worst case p=12p = \tfrac12 gives about 1,070); twenty benchmarks at once need about 3,700. The same two steps — Hoeffding for one hypothesis, a union bound over a finite hypothesis class — give the generalisation bound in learning as optimisation, and the union bound is the Bonferroni correction you owe when scanning many benchmarks for a significant difference.

The bootstrap

When the statistic is not a simple mean — a median, a ratio, a win rate against a reference, a correlation, an average of per-problem pass@k values — there may be no convenient formula for its standard error. The bootstrap substitutes computation: treat the empirical distribution as the population, draw BB resamples of size nn with replacement, recompute the statistic on each, and use the spread of the BB values as its sampling distribution. The standard deviation of the bootstrap replicates estimates the standard error; their 2.5th and 97.5th percentiles give a percentile interval. Two rules matter in practice: resample the unit that is independent (questions, not samples within a question; clusters of related questions, not single questions), and remember the bootstrap estimates variance, it does not remove bias.

NumPy Coverage of Wald vs Wilson; a bootstrap interval
import numpy as np
rng = np.random.default_rng(1)

def wald(k, n, z=1.96):
    ph = k / n; h = z * np.sqrt(ph * (1 - ph) / n); return ph - h, ph + h
def wilson(k, n, z=1.96):
    ph = k / n; den = 1 + z*z/n; c = (ph + z*z/(2*n)) / den
    h = z / den * np.sqrt(ph*(1-ph)/n + z*z/(4*n*n)); return c - h, c + h

print("coverage of nominal 95% intervals (100k simulated benchmarks)")
for p, n in [(0.7, 200), (0.95, 20), (0.95, 100), (0.99, 50)]:
    k = rng.binomial(n, p, size=100_000)
    cov = [np.mean((lo <= p) & (p <= hi)) for lo, hi in (wald(k, n), wilson(k, n))]
    print(f"  p={p:.2f} n={n:4d}:  Wald {cov[0]:.3f}   Wilson {cov[1]:.3f}")

# bootstrap: a statistic without a simple formula (the median of per-question scores)
scores = rng.beta(2, 5, size=300)                  # e.g. per-question rubric scores in [0, 1]
B = 4000
idx = rng.integers(0, scores.size, size=(B, scores.size)).astype(np.intp)
boot_mean = scores[idx].mean(1)
boot_med = np.median(scores[idx], axis=1)
print(f"\nbootstrap se of the mean {boot_mean.std():.4f}   vs s/sqrt(n) {scores.std(ddof=1)/np.sqrt(scores.size):.4f}")
lo, hi = np.percentile(boot_med, [2.5, 97.5])
print(f"median {np.median(scores):.4f}, 95% percentile-bootstrap CI [{lo:.4f}, {hi:.4f}]")
 

Importance sampling and the effective sample size

To estimate Eπ[f]\mathbb{E}_\pi[f] with samples from a different distribution qq, reweight:

Ex∼π[f(x)]=∑xq(x) π(x)q(x) f(x)=Ex∼q[w(x) f(x)],w=πq,\mathbb{E}_{x\sim\pi}[f(x)] = \sum_x q(x)\,\frac{\pi(x)}{q(x)}\,f(x) = \mathbb{E}_{x\sim q}\big[w(x)\,f(x)\big], \qquad w = \frac{\pi}{q},

valid when q>0q > 0 wherever πf≠0\pi f \ne 0. The estimator 1N∑iwif(xi)\frac1N\sum_i w_i f(x_i) is unbiased, but its variance is governed by the second moment of the weights, Eq[w2]=∑xπ(x)2/q(x)=1+χ2(π∥q)\mathbb{E}_q[w^2] = \sum_x \pi(x)^2/q(x) = 1 + \chi^2(\pi\|q), which explodes wherever qq is much smaller than π\pi. A one-number summary is the effective sample size

ESS=(∑iwi)2∑iwi2  ≈  NEq[w2],\mathrm{ESS} = \frac{\big(\sum_i w_i\big)^2}{\sum_i w_i^2} \;\approx\; \frac{N}{\mathbb{E}_q[w^2]} ,

which equals NN for equal weights and 1 when a single weight dominates. For a Gaussian shifted by dd standard deviations, Eq[w2]=ed2\mathbb{E}_q[w^2] = e^{d^2}: at d=2d = 2 fewer than 2% of the samples are effectively used. When π\pi is known only up to a constant (or to cut variance) one uses self-normalised IS ∑iwif(xi)/∑iwi\sum_i w_i f(x_i)/\sum_i w_i, which is biased by O(1/N)O(1/N) but consistent.

집중 부등식: Hoeffding과 union bound

CLT는 점근적이다. 유한한 nn에서 보장이 필요하면 집중 부등식을 쓴다. 독립인 xi∈[a,b]x_i \in [a, b]에 대해 Hoeffding 부등식은

P(∣xˉn−μ∣≥ε)≤2exp⁡ ⁣(−2nε2(b−a)2)P\big(|\bar x_n - \mu| \ge \varepsilon\big) \le 2\exp\!\Big(-\frac{2n\varepsilon^2}{(b-a)^2}\Big)

을 준다. CLT와 같은 ε∝1/n\varepsilon \propto 1/\sqrt n 스케일이지만 근사도 분산 추정도 없다(범위만 쓰므로 분산이 작으면 느슨하다). 이런 명제 KK개가 동시에 성립하게 하려면 union bound P(∪kAk)≤∑kP(Ak)P(\cup_k A_k) \le \sum_k P(A_k)로 실패 확률에 KK를 곱한다. 그러면 n≥(b−a)22ε2log⁡2Kδn \ge \frac{(b-a)^2}{2\varepsilon^2}\log\frac{2K}{\delta}이면 확률 1−δ1 - \delta로 KK개 평균이 모두 ε\varepsilon 안에 든다. 비교 KK개의 대가는 log⁡K\log K뿐이다. 0/1 정확도, ε=3\varepsilon = 3포인트, δ=0.05\delta = 0.05이면 벤치마크 하나에 n≥log⁡40/(2⋅0.032)≈2,050n \ge \log 40/(2\cdot 0.03^2) \approx 2{,}050문항이 필요하다(CLT의 최악 경우 p=12p = \tfrac12는 약 1,070). 벤치마크 스무 개를 동시에 보장하려면 약 3,700문항이다. 같은 두 단계, 즉 가설 하나에 대한 Hoeffding과 유한 가설 집합 위의 union bound가 최적화로서의 학습의 일반화 bound를 주고, union bound는 여러 벤치마크를 훑으며 유의한 차이를 찾을 때 치러야 하는 Bonferroni 보정이다.

부트스트랩

통계량이 단순 평균이 아니면, 예를 들어 중앙값, 비율, 기준 모델 대비 승률, 상관계수, 문제별 pass@k의 평균이면, 표준오차를 구하는 편리한 공식이 없을 수 있다. 부트스트랩은 계산으로 대신한다. 경험 분포를 모집단으로 보고, 크기 nn의 재표본을 복원추출로 BB번 뽑아 각각에서 통계량을 다시 계산하고, 그 BB개 값의 퍼짐을 표본분포로 쓴다. 부트스트랩 복제값의 표준편차가 표준오차의 추정이고, 2.5·97.5 백분위가 백분위 구간이다. 실전에서 중요한 규칙 둘. 독립인 단위를 재추출하라(문항 안의 샘플이 아니라 문항을, 관련 문항들의 묶음이 있으면 개별 문항이 아니라 묶음을). 그리고 부트스트랩은 분산을 추정할 뿐 편향을 없애지 않는다.

NumPy Wald와 Wilson의 포함률; 부트스트랩 구간
import numpy as np
rng = np.random.default_rng(1)

def wald(k, n, z=1.96):
    ph = k / n; h = z * np.sqrt(ph * (1 - ph) / n); return ph - h, ph + h
def wilson(k, n, z=1.96):
    ph = k / n; den = 1 + z*z/n; c = (ph + z*z/(2*n)) / den
    h = z / den * np.sqrt(ph*(1-ph)/n + z*z/(4*n*n)); return c - h, c + h

print("명목 95% 구간의 포함률 (시뮬레이션 벤치마크 10만 회)")
for p, n in [(0.7, 200), (0.95, 20), (0.95, 100), (0.99, 50)]:
    k = rng.binomial(n, p, size=100_000)
    cov = [np.mean((lo <= p) & (p <= hi)) for lo, hi in (wald(k, n), wilson(k, n))]
    print(f"  p={p:.2f} n={n:4d}:  Wald {cov[0]:.3f}   Wilson {cov[1]:.3f}")

# 부트스트랩: 단순한 공식이 없는 통계량 (문항별 점수의 중앙값)
scores = rng.beta(2, 5, size=300)                  # 예: [0, 1] 범위의 문항별 rubric 점수
B = 4000
idx = rng.integers(0, scores.size, size=(B, scores.size)).astype(np.intp)
boot_mean = scores[idx].mean(1)
boot_med = np.median(scores[idx], axis=1)
print(f"\n평균의 부트스트랩 se {boot_mean.std():.4f}   vs s/sqrt(n) {scores.std(ddof=1)/np.sqrt(scores.size):.4f}")
lo, hi = np.percentile(boot_med, [2.5, 97.5])
print(f"중앙값 {np.median(scores):.4f}, 95% 백분위 부트스트랩 구간 [{lo:.4f}, {hi:.4f}]")
 

Importance sampling과 유효 표본 크기

다른 분포 qq의 샘플로 Eπ[f]\mathbb{E}_\pi[f]를 추정하려면 가중치를 다시 매긴다.

Ex∼π[f(x)]=∑xq(x) π(x)q(x) f(x)=Ex∼q[w(x) f(x)],w=πq,\mathbb{E}_{x\sim\pi}[f(x)] = \sum_x q(x)\,\frac{\pi(x)}{q(x)}\,f(x) = \mathbb{E}_{x\sim q}\big[w(x)\,f(x)\big], \qquad w = \frac{\pi}{q},

πf≠0\pi f \ne 0인 곳에서 q>0q > 0이면 성립한다. 추정량 1N∑iwif(xi)\frac1N\sum_i w_i f(x_i)는 불편이지만, 분산은 가중치의 2차 적률 Eq[w2]=∑xπ(x)2/q(x)=1+χ2(π∥q)\mathbb{E}_q[w^2] = \sum_x \pi(x)^2/q(x) = 1 + \chi^2(\pi\|q)가 좌우하고, 이것은 qq가 π\pi보다 훨씬 작은 곳에서 폭발한다. 한 숫자로 요약한 것이 유효 표본 크기(ESS) 다.

ESS=(∑iwi)2∑iwi2  ≈  NEq[w2]\mathrm{ESS} = \frac{\big(\sum_i w_i\big)^2}{\sum_i w_i^2} \;\approx\; \frac{N}{\mathbb{E}_q[w^2]}

가중치가 모두 같으면 NN, 하나가 지배하면 1이다. 표준편차 dd개만큼 이동한 Gaussian이면 Eq[w2]=ed2\mathbb{E}_q[w^2] = e^{d^2}이다. d=2d = 2면 실질적으로 쓰이는 샘플이 2%도 안 된다. π\pi를 상수배까지만 알 때(또는 분산을 줄이려고) self-normalised IS ∑iwif(xi)/∑iwi\sum_i w_i f(x_i)/\sum_i w_i를 쓴다. O(1/N)O(1/N)만큼 편향되지만 일치 추정량이다.

ESS/N – 이론theory 1/Eq[w²] – 최대 가중치 몫largest weight share – SNIS Eπ[x] – (참값(truth –)
We want averages under the target π = N(d, 1) (blue) but can only sample the proposal q = N(0, s²) (grey). Each of the N = 300 samples gets weight w = π(x)/q(x); red sticks show the normalised weights. At d = 0 and s = 1 the proposal is the target, all weights are 1 and ESS = N (at d = 0, s = 2 the weight at x = 0 is already 2 and the theoretical ESS/N is √7/4 ≈ 0.66). Slide d to 2: a handful of samples in the right tail carry almost all the weight, the ESS collapses (theory e−d² for s = 1), and the estimate jumps around when you Resample. A wider proposal (s ≈ 1.5–2) covers the target's tail and recovers much of the ESS. In general Eq[w²] = s/√(2a)·ed²(1/a − 1) with a = 1 − 1/(2s²), valid for s > 1/√2; for s ≤ 1/√2 (a ≤ 0, boundary included) the integral diverges and the weight variance is infinite. 목표 분포 π = N(d, 1)(파랑) 아래의 평균이 필요한데 제안 분포 q = N(0, s²)(회색)에서만 샘플할 수 있다. N = 300개 샘플이 각자 가중치 w = π(x)/q(x)를 받는다. 빨간 막대가 정규화된 가중치다. d = 0이고 s = 1이면 제안 분포가 곧 목표 분포라 가중치가 모두 1이고 ESS = N이다(d = 0, s = 2만 해도 x = 0의 가중치가 2이고 이론 ESS/N은 √7/4 ≈ 0.66이다). d를 2로 밀면 오른쪽 꼬리의 샘플 몇 개가 가중치를 거의 다 가져가고, ESS가 무너지며(s = 1이면 이론값 e−d²), 다시 샘플할 때마다 추정값이 크게 흔들린다. 더 넓은 제안 분포(s ≈ 1.5–2)가 목표의 꼬리를 덮어 ESS를 상당 부분 되찾는다. 일반적으로 a = 1 − 1/(2s²)일 때 Eq[w²] = s/√(2a)·ed²(1/a − 1)이고 s > 1/√2에서 성립한다. s ≤ 1/√2(a ≤ 0, 경계 포함)이면 적분이 발산해 가중치 분산이 무한대가 된다.

Why this bites LLMs. For a sequence the weight is a product of per-token ratios, log⁡w=∑t=1Tlog⁡ρt\log w = \sum_{t=1}^T \log\rho_t. If the per-token log-ratios are roughly independent with variance s2s^2 (and mean −s2/2-s^2/2, so that E[ρt]=1\mathbb{E}[\rho_t] = 1), then log⁡w∼N(−Ts2/2, Ts2)\log w \sim \mathcal{N}(-Ts^2/2,\ Ts^2) and

E[w2]=eTs2⇒ESSN≈e−Ts2.\mathbb{E}[w^2] = e^{Ts^2} \quad\Rightarrow\quad \frac{\mathrm{ESS}}{N} \approx e^{-Ts^2}.

A per-token mismatch too small to notice (s2=0.005s^2 = 0.005) leaves 37% of the samples at T=200T = 200 and under 2% at T=800T = 800. This exponential collapse is why sequence-level IS is impractical for long responses, why PPO uses per-token ratios with clipping, and why truncated or masked weights (TIS, IcePop, CISPO’s clipped IS weight) trade bias for bounded variance (off-policy mismatch, clipping and IS, verl rollout correction).

NumPy Importance sampling: ESS for a shifted Gaussian and for long sequences
import numpy as np
rng = np.random.default_rng(2)

def ess_frac(logw):
    w = np.exp(logw - logw.max()); return w.sum() ** 2 / (w ** 2).sum() / w.size

N = 10_000
x = rng.normal(size=N)                             # proposal q = N(0, 1)
print("target N(d,1), proposal N(0,1)")
for d in [0.0, 0.5, 1.0, 2.0]:
    logw = -0.5 * (x - d) ** 2 + 0.5 * x ** 2      # log pi(x) - log q(x)
    w = np.exp(logw)
    is_est = np.mean(w * x)                        # unbiased
    snis = np.sum(w * x) / np.sum(w)               # self-normalised: biased, consistent
    print(f"  d={d}: ESS/N {ess_frac(logw):.4f} (theory e^-d^2 = {np.exp(-d*d):.4f})   IS {is_est:+.3f}  SNIS {snis:+.3f}  truth {d}")

# sequence-level weight = product of T per-token ratios
s2 = 0.005                                         # variance of one token's log-ratio
print(f"\nsequence-level IS, per-token log-ratio variance {s2}:")
for T in [10, 50, 200, 800]:
    logw = rng.normal(-s2 / 2, np.sqrt(s2), size=(4000, T)).sum(1)   # E[rho_t] = 1
    print(f"  T={T:4d}: ESS/N {ess_frac(logw):.3f}   (theory exp(-T s2) = {np.exp(-T*s2):.3f})")
 

At the largest shifts the empirical ESS is above the theory: a finite sample has not yet drawn the rare, huge weights that dominate E[w2]\mathbb{E}[w^2], so it looks healthier than it is. Treat a moderate ESS from heavy-tailed weights with suspicion.

Control variates — what a baseline is

If hh is correlated with ff and E[h]\mathbb{E}[h] is known, then f−c (h−Eh)f - c\,(h - \mathbb{E}h) has the same mean as ff for every cc, and variance

Var(f)−2c Cov(f,h)+c2 Var(h),\mathrm{Var}(f) - 2c\,\mathrm{Cov}(f, h) + c^2\,\mathrm{Var}(h),

a parabola in cc minimised at c∗=Cov(f,h)/Var(h)c^* = \mathrm{Cov}(f,h)/\mathrm{Var}(h), where it equals (1−ρfh2) Var(f)(1 - \rho_{fh}^2)\,\mathrm{Var}(f). A 0.9 correlation removes 81% of the variance.

Two control variates run through the RL tracks. The policy-gradient baseline: h=∇log⁡πθ(y)h = \nabla\log\pi_\theta(y) has known mean 0, and subtracting b ∇log⁡πθb\,\nabla\log\pi_\theta is a control variate with coefficient bb — unbiased for any bb that does not depend on yy, best near E[f ∥∇log⁡π∥2]/E[∥∇log⁡π∥2]\mathbb{E}[f\,\|\nabla\log\pi\|^2]/\mathbb{E}[\|\nabla\log\pi\|^2], usually approximated by the expected reward (value function, group mean, leave-one-out mean; policy gradient, RLVR and GRPO). And the k3k_3 KL estimator k3=k1+(r−1)k_3 = k_1 + (r - 1) with r=πref/πθr = \pi_{\text{ref}}/\pi_\theta: Eπθ[r−1]=0\mathbb{E}_{\pi_\theta}[r - 1] = 0, so it is k1k_1 plus a control variate with fixed coefficient 1, which is close to optimal when πθ≈πref\pi_\theta\approx\pi_{\text{ref}} (KL-regularised RL).

NumPy Control variates: the optimal coefficient, and k3 as k1 + (r − 1)
import numpy as np
rng = np.random.default_rng(3)

# estimate E[exp(U)], U ~ Unif(0,1); control variate h = U with known mean 1/2
U = rng.random(size=(5000, 32))
f, h = np.exp(U), U
c_star = np.cov(f.ravel(), h.ravel())[0, 1] / h.var()
plain = f.mean(1)
cv = (f - c_star * (h - 0.5)).mean(1)
rho = np.corrcoef(f.ravel(), h.ravel())[0, 1]
print(f"control variate: c* = {c_star:.3f}, variance ratio {cv.var()/plain.var():.4f}  (theory 1 - rho^2 = {1 - rho**2:.4f})")
print(f"  both unbiased: plain {plain.mean():.4f}, cv {cv.mean():.4f}, truth e-1 = {np.e - 1:.4f}")

# KL estimators: k3 = k1 + (r - 1), a zero-mean control variate with coefficient 1
z = rng.normal(size=50)
for name, scale in [("close", 0.1), ("far", 1.0)]:
    pi = np.exp(z) / np.exp(z).sum()
    zr = z + scale * rng.normal(size=50); ref = np.exp(zr) / np.exp(zr).sum()
    y = rng.choice(50, size=200_000, p=pi).astype(np.intp)
    r = ref[y] / pi[y]
    k1, k3 = -np.log(r), r - 1 - np.log(r)
    print(f"{name:5s}: KL {np.sum(pi*np.log(pi/ref)):.4f} | k1 mean {k1.mean():.4f} sd {k1.std():.3f} | k3 mean {k3.mean():.4f} sd {k3.std():.3f}")
 

Near the reference, k3k_3‘s standard deviation is more than an order of magnitude below k1k_1‘s; far from it the fixed coefficient 1 is no longer optimal and the advantage shrinks (it can even reverse).

The statistics of evaluation

pass@k. For one problem with per-sample success probability pp, pass@k =1−(1−p)k= 1 - (1-p)^k, the probability that at least one of kk independent samples is correct; a benchmark averages this over problems. The obvious estimator — draw n≥kn \ge k samples, count cc correct, plug in p^=c/n\hat p = c/n — is biased low: (1−p)k(1-p)^k is convex in pp, so by Jensen E[(1−p^)k]≥(1−p)k\mathbb{E}[(1-\hat p)^k] \ge (1-p)^k (optimisation). The unbiased estimator of Chen et al. (2021) instead asks: if we pick kk of the nn samples uniformly without replacement, what is the chance that all are wrong?

pass@k^=1−(n−ck)(nk)=1−∏i=n−c+1n(1−ki).\widehat{\text{pass@}k} = 1 - \frac{\binom{n-c}{k}}{\binom{n}{k}} = 1 - \prod_{i=n-c+1}^{n}\Big(1 - \frac{k}{i}\Big).

It is unbiased because a uniformly random kk-subset of nn iid samples is itself kk iid samples, so the probability that the subset is all-wrong has expectation (1−p)k(1-p)^k. The product form avoids huge binomial coefficients. pass@1 estimated as the mean accuracy over kk samples per problem (as reasoning reports do) is the k=1k=1 case.

How noisy is a benchmark score? With nn questions of varying difficulty pip_i and KK samples per question, the score’s variance has two parts (Miller, 2024):

Var(score)=1n(Vari(pi)⏟which questions+Ei[pi(1−pi)]K⏟which samples).\mathrm{Var}(\text{score}) = \frac{1}{n}\Big(\underbrace{\mathrm{Var}_i(p_i)}_{\text{which questions}} + \underbrace{\frac{\mathbb{E}_i[p_i(1-p_i)]}{K}}_{\text{which samples}}\Big).

Sampling more per question only shrinks the second term. If you ask “would I get the same number re-running this exact benchmark?”, only the second term applies; if you ask “is this model better at this kind of problem?”, both do. On a 30-question benchmark like AIME, a spread of per-question solve rates with standard deviation 0.3 alone gives se≈0.3/30≈5.5\mathrm{se} \approx 0.3/\sqrt{30} \approx 5.5 points — no number of samples per question removes it.

How many questions to separate two models? Score both models on the same questions and analyse the per-question differences di=ai−bid_i = a_i - b_i: se=sd(d)/n\mathrm{se} = \mathrm{sd}(d)/\sqrt n. Pairing removes the shared difficulty: Var(di)=Var(ai)+Var(bi)−2 Cov(ai,bi)\mathrm{Var}(d_i) = \mathrm{Var}(a_i) + \mathrm{Var}(b_i) - 2\,\mathrm{Cov}(a_i, b_i). To detect a true gap Δ\Delta with 80% power at two-sided α=0.05\alpha = 0.05 you need Δ≥(1.96+0.84) se=2.8 se\Delta \ge (1.96 + 0.84)\,\mathrm{se} = 2.8\,\mathrm{se}, i.e.

n  ≳  (2.8 σdΔ)2.n \;\gtrsim\; \Big(\frac{2.8\,\sigma_d}{\Delta}\Big)^2 .

At accuracy around 70% with independent errors (σd2=2⋅0.21\sigma_d^2 = 2\cdot 0.21), a 2-point gap needs about 7.84×0.42/0.0004≈8,2007.84 \times 0.42/0.0004 \approx 8{,}200 questions; a correlation of 0.5 between the models’ per-question correctness halves that. Most single-benchmark differences of a point or two in a report table are inside the noise.

NumPy pass@k, benchmark variance, paired comparisons
import numpy as np
from math import comb
rng = np.random.default_rng(4)

def pass_at_k(n, c, k):
    """Unbiased pass@k from n samples with c correct (Chen et al., 2021), stable product form."""
    if n - c < k: return 1.0
    return 1.0 - np.prod(1.0 - k / np.arange(n - c + 1, n + 1))

n, k, p = 20, 5, 0.15                              # 20 samples per problem, per-sample success 0.15
true = 1 - (1 - p) ** k
c = rng.binomial(n, p, size=200_000)
unb = np.array([pass_at_k(n, ci, k) for ci in range(n + 1)])[c.astype(np.intp)]
naive = 1 - (1 - c / n) ** k
print(f"pass@{k} with n={n}, p={p}: truth {true:.4f}   unbiased {unb.mean():.4f}   naive plug-in {naive.mean():.4f}")
print(f"product form == 1 - C(n-c,k)/C(n,k): {np.isclose(pass_at_k(20, 3, 5), 1 - comb(17, 5) / comb(20, 5))}")

# benchmark variance: questions differ in difficulty p_i; K samples per question
nq = 500
for K in [1, 4, 16]:
    pq = rng.beta(0.6, 0.6, size=(2000, nq))       # a fresh question set per run
    total = (rng.binomial(K, pq) / K).mean(1)
    fixed = rng.beta(0.6, 0.6, size=nq)            # one fixed question set, model re-run
    rerun = (rng.binomial(K, fixed, size=(2000, nq)) / K).mean(1)
    th_tot = np.sqrt((pq.var() + np.mean(pq * (1 - pq)) / K) / nq)
    th_fix = np.sqrt(np.mean(fixed * (1 - fixed)) / K / nq)
    print(f"K={K:2d}: new questions sd {total.std():.4f} (theory {th_tot:.4f}) | re-run sd {rerun.std():.4f} (theory {th_fix:.4f})")

# two models on the same 500 questions: B is ~3 points better on every question
pa = rng.beta(0.6, 0.6, size=nq); pb = np.clip(pa + 0.03, 0, 1)
a = (rng.random((2000, nq)) < pa).astype(float); b = (rng.random((2000, nq)) < pb).astype(float)
gap = b.mean(1) - a.mean(1)
se_paired = (b - a).std(1, ddof=1) / np.sqrt(nq)
pa_hat, pb_hat = a.mean(1), b.mean(1)
se_naive = np.sqrt((pa_hat*(1-pa_hat) + pb_hat*(1-pb_hat)) / nq)
print(f"\nmean observed gap {gap.mean():.4f}, its actual sd {gap.std():.4f}")
print(f"  naive two-proportion se {se_naive.mean():.4f}   paired se sd(d_i)/sqrt(n) {se_paired.mean():.4f}")
print(f"  power at alpha=0.05: naive {np.mean(gap/se_naive > 1.96):.2f}   paired {np.mean(gap/se_paired > 1.96):.2f}")
 

The naive two-proportion standard error ignores that both models face the same questions and overstates the noise; the paired one matches the actual spread. Even paired, a 3-point gap on 500 questions is detected only a minority of the time — the minimum detectable difference here is about 2.8×0.024≈72.8 \times 0.024 \approx 7 points.

확인 문제Check yourself

A benchmark has 200 questions and model accuracy is about 60%. Roughly how many questions would you need for a 95% interval half as wide?

The half-width is 1.96p(1−p)/n1.96\sqrt{p(1-p)/n}, proportional to 1/n1/\sqrt n. Halving it needs 4×4\times the questions: 800. (Here about ±6.8\pm 6.8 points at n=200n = 200, ±3.4\pm 3.4 at n=800n = 800.) More samples per question shrink only the within-question part of the variance, not the part due to which questions were chosen.

확인 문제Check yourself

You estimate pass@10 by sampling 10 responses per problem and scoring 1 if any is correct. Then you instead sample 50 per problem and plug c/50 into 1 − (1 − p)^10. Which statement is right?

With exactly n=k=10n = k = 10 samples, “any correct” is the unbiased estimator (1−(10−c10)/(1010)1 - \binom{10-c}{10}/\binom{10}{10} is 1 if c>0c > 0 and 0 otherwise). The plug-in 1−(1−p^)101 - (1 - \hat p)^{10} applies the convex map p↦(1−p)10p \mapsto (1-p)^{10} to an unbiased p^\hat p, so E[(1−p^)10]≥(1−p)10\mathbb{E}[(1-\hat p)^{10}] \ge (1-p)^{10} and pass@10 is under-estimated. With 50 samples, use 1−(50−c10)/(5010)1 - \binom{50-c}{10}/\binom{50}{10} instead: unbiased and lower-variance than the 10-sample version.

Summary

  • MSE = bias² + variance; unbiased is not the same as accurate (dividing by n+1n+1 beats n−1n-1 for Gaussian variance).
  • MLE maximises ∑log⁡pθ(xi)\sum\log p_\theta(x_i) = minimises cross-entropy; p^=k/n\hat p = k/n, μ^=xˉ\hat\mu = \bar x, σ^2=1n∑(x−xˉ)2\hat\sigma^2 = \frac1n\sum(x-\bar x)^2; asymptotic variance 1/(nI)1/(nI), so se(p^)=p(1−p)/n\mathrm{se}(\hat p) = \sqrt{p(1-p)/n}.
  • CLT: xˉ±1.96 s/n\bar x \pm 1.96\,s/\sqrt n. For proportions near 0 or 1 or small nn, prefer Wilson to Wald. Width ∝1/n\propto 1/\sqrt n.
  • Hoeffding: P(∣xˉ−μ∣≥ε)≤2e−2nε2/(b−a)2P(|\bar x - \mu| \ge \varepsilon) \le 2e^{-2n\varepsilon^2/(b-a)^2} at any nn; a union bound over KK statements costs only log⁡K\log K.
  • Bootstrap: resample the independent unit with replacement; spread of replicates = standard error.
  • IS: Eπf=Eq[wf]\mathbb{E}_\pi f = \mathbb{E}_q[wf]; ESS≈N/Eq[w2]\mathrm{ESS} \approx N/\mathbb{E}_q[w^2]; sequence weights give ESS/N≈e−Ts2\mathrm{ESS}/N \approx e^{-Ts^2}.
  • Control variates: f−c(h−Eh)f - c(h - \mathbb{E}h), variance (1−ρ2)Varf(1-\rho^2)\mathrm{Var}f at c∗c^*. Baselines and k3k_3 are control variates.
  • Evaluation: unbiased pass@k =1−(n−ck)/(nk)= 1 - \binom{n-c}{k}/\binom nk; score variance = question variance + sampling variance/KK, all over nn; separate models with paired differences and n≳(2.8σd/Δ)2n \gtrsim (2.8\sigma_d/\Delta)^2.

Where this is used

LLM에서 이것이 아픈 이유. 시퀀스의 가중치는 토큰별 비의 곱이다: log⁡w=∑t=1Tlog⁡ρt\log w = \sum_{t=1}^T \log\rho_t. 토큰별 log-ratio가 대략 독립이고 분산 s2s^2(평균 −s2/2-s^2/2, 그래서 E[ρt]=1\mathbb{E}[\rho_t] = 1)이면 log⁡w∼N(−Ts2/2, Ts2)\log w \sim \mathcal{N}(-Ts^2/2,\ Ts^2)이고

E[w2]=eTs2⇒ESSN≈e−Ts2.\mathbb{E}[w^2] = e^{Ts^2} \quad\Rightarrow\quad \frac{\mathrm{ESS}}{N} \approx e^{-Ts^2}.

눈치채기 어려울 만큼 작은 토큰별 불일치(s2=0.005s^2 = 0.005)도 T=200T = 200에서는 샘플의 37%, T=800T = 800에서는 2% 미만만 남긴다. 이 지수적 붕괴가 긴 응답에서 시퀀스 단위 IS를 쓸 수 없는 이유이고, PPO가 토큰 단위 ratio에 clip을 쓰는 이유이며, 잘리거나 가려진 가중치(TIS, IcePop, CISPO의 clip된 IS 가중치)가 유계 분산을 위해 편향을 감수하는 이유다(off-policy 불일치, clipping과 IS, verl rollout correction).

NumPy Importance sampling: 이동한 Gaussian과 긴 시퀀스의 ESS
import numpy as np
rng = np.random.default_rng(2)

def ess_frac(logw):
    w = np.exp(logw - logw.max()); return w.sum() ** 2 / (w ** 2).sum() / w.size

N = 10_000
x = rng.normal(size=N)                             # 제안 분포 q = N(0, 1)
print("목표 N(d,1), 제안 N(0,1)")
for d in [0.0, 0.5, 1.0, 2.0]:
    logw = -0.5 * (x - d) ** 2 + 0.5 * x ** 2      # log pi(x) - log q(x)
    w = np.exp(logw)
    is_est = np.mean(w * x)                        # 불편
    snis = np.sum(w * x) / np.sum(w)               # self-normalised: 편향, 일치
    print(f"  d={d}: ESS/N {ess_frac(logw):.4f} (이론 e^-d^2 = {np.exp(-d*d):.4f})   IS {is_est:+.3f}  SNIS {snis:+.3f}  참값 {d}")

# 시퀀스 단위 가중치 = 토큰별 비 T개의 곱
s2 = 0.005                                         # 토큰 하나의 log-ratio 분산
print(f"\n시퀀스 단위 IS, 토큰별 log-ratio 분산 {s2}:")
for T in [10, 50, 200, 800]:
    logw = rng.normal(-s2 / 2, np.sqrt(s2), size=(4000, T)).sum(1)   # E[rho_t] = 1
    print(f"  T={T:4d}: ESS/N {ess_frac(logw):.3f}   (이론 exp(-T s2) = {np.exp(-T*s2):.3f})")
 

이동이 가장 클 때 경험 ESS가 이론보다 크다. 유한 표본은 E[w2]\mathbb{E}[w^2]를 지배하는 드물고 거대한 가중치를 아직 뽑지 못했기 때문에 실제보다 건강해 보인다. 꼬리가 두꺼운 가중치에서 나온 그럴듯한 ESS는 의심하라.

Control variate: baseline의 정체

hh가 ff와 상관되어 있고 E[h]\mathbb{E}[h]를 안다면, f−c (h−Eh)f - c\,(h - \mathbb{E}h)는 모든 cc에 대해 ff와 평균이 같고 분산은

Var(f)−2c Cov(f,h)+c2 Var(h)\mathrm{Var}(f) - 2c\,\mathrm{Cov}(f, h) + c^2\,\mathrm{Var}(h)

이다. cc에 대한 포물선이고 c∗=Cov(f,h)/Var(h)c^* = \mathrm{Cov}(f,h)/\mathrm{Var}(h)에서 최소이며, 그때 값은 (1−ρfh2) Var(f)(1 - \rho_{fh}^2)\,\mathrm{Var}(f)다. 상관 0.9면 분산의 81%가 사라진다.

RL 트랙에는 control variate 두 개가 흐른다. 정책 경사의 baseline: h=∇log⁡πθ(y)h = \nabla\log\pi_\theta(y)는 평균이 0으로 알려져 있고, b ∇log⁡πθb\,\nabla\log\pi_\theta를 빼는 것은 계수 bb인 control variate다. yy에 의존하지 않는 어떤 bb에 대해서도 불편이고, 최적값은 E[f ∥∇log⁡π∥2]/E[∥∇log⁡π∥2]\mathbb{E}[f\,\|\nabla\log\pi\|^2]/\mathbb{E}[\|\nabla\log\pi\|^2] 근처이며, 보통 기대 보상(value function, 그룹 평균, leave-one-out 평균)으로 근사한다(정책 경사, RLVR과 GRPO). 그리고 r=πref/πθr = \pi_{\text{ref}}/\pi_\theta일 때 k3k_3 KL 추정량 k3=k1+(r−1)k_3 = k_1 + (r - 1): Eπθ[r−1]=0\mathbb{E}_{\pi_\theta}[r - 1] = 0이므로 k1k_1에 계수 1로 고정된 control variate를 더한 것이고, πθ≈πref\pi_\theta\approx\pi_{\text{ref}}일 때 그 계수가 최적에 가깝다(KL 정규화 RL).

NumPy Control variate: 최적 계수, 그리고 k1 + (r − 1)로서의 k3
import numpy as np
rng = np.random.default_rng(3)

# E[exp(U)], U ~ Unif(0,1) 추정; 평균 1/2을 아는 control variate h = U
U = rng.random(size=(5000, 32))
f, h = np.exp(U), U
c_star = np.cov(f.ravel(), h.ravel())[0, 1] / h.var()
plain = f.mean(1)
cv = (f - c_star * (h - 0.5)).mean(1)
rho = np.corrcoef(f.ravel(), h.ravel())[0, 1]
print(f"control variate: c* = {c_star:.3f}, 분산 비 {cv.var()/plain.var():.4f}  (이론 1 - rho^2 = {1 - rho**2:.4f})")
print(f"  둘 다 불편: 기본 {plain.mean():.4f}, cv {cv.mean():.4f}, 참값 e-1 = {np.e - 1:.4f}")

# KL 추정량: k3 = k1 + (r - 1), 계수 1인 평균 0의 control variate
z = rng.normal(size=50)
for name, scale in [("close", 0.1), ("far", 1.0)]:
    pi = np.exp(z) / np.exp(z).sum()
    zr = z + scale * rng.normal(size=50); ref = np.exp(zr) / np.exp(zr).sum()
    y = rng.choice(50, size=200_000, p=pi).astype(np.intp)
    r = ref[y] / pi[y]
    k1, k3 = -np.log(r), r - 1 - np.log(r)
    print(f"{name:5s}: KL {np.sum(pi*np.log(pi/ref)):.4f} | k1 평균 {k1.mean():.4f} sd {k1.std():.3f} | k3 평균 {k3.mean():.4f} sd {k3.std():.3f}")
 

reference 근처에서 k3k_3의 표준편차는 k1k_1보다 한 자릿수 이상 작다. 멀어지면 고정 계수 1이 더는 최적이 아니라서 이점이 줄어든다(뒤집힐 수도 있다).

평가의 통계

pass@k. 샘플당 성공 확률이 pp인 문제 하나에서 pass@k =1−(1−p)k= 1 - (1-p)^k, 독립 샘플 kk개 중 적어도 하나가 맞을 확률이다. 벤치마크는 이것을 문제들에 대해 평균한다. 당연해 보이는 추정량, 즉 n≥kn \ge k개를 뽑아 맞은 수 cc를 세고 p^=c/n\hat p = c/n을 대입하는 것은 낮게 편향된다. (1−p)k(1-p)^k가 pp에 대해 볼록이므로 Jensen에 의해 E[(1−p^)k]≥(1−p)k\mathbb{E}[(1-\hat p)^k] \ge (1-p)^k이다(최적화). Chen et al.(2021)의 불편 추정량은 대신 이렇게 묻는다. nn개 샘플 중 kk개를 비복원으로 균등하게 고르면 모두 틀릴 확률은?

pass@k^=1−(n−ck)(nk)=1−∏i=n−c+1n(1−ki).\widehat{\text{pass@}k} = 1 - \frac{\binom{n-c}{k}}{\binom{n}{k}} = 1 - \prod_{i=n-c+1}^{n}\Big(1 - \frac{k}{i}\Big).

iid 샘플 nn개 중 균등하게 고른 kk개 부분집합은 그 자체로 iid 샘플 kk개이므로, 부분집합이 모두 틀릴 확률의 기댓값이 (1−p)k(1-p)^k이다. 그래서 불편이다. 곱 형태는 거대한 이항계수를 피한다. 추론 보고서들처럼 문제당 kk개 샘플의 평균 정확도로 추정한 pass@1은 k=1k=1인 경우다.

벤치마크 점수는 얼마나 흔들리는가? 난이도 pip_i가 제각각인 문항 nn개에서 문항당 KK개를 샘플하면 점수의 분산은 두 부분이다(Miller, 2024).

Var(점수)=1n(Vari(pi)⏟어떤 문항인가+Ei[pi(1−pi)]K⏟어떤 샘플인가).\mathrm{Var}(\text{점수}) = \frac{1}{n}\Big(\underbrace{\mathrm{Var}_i(p_i)}_{\text{어떤 문항인가}} + \underbrace{\frac{\mathbb{E}_i[p_i(1-p_i)]}{K}}_{\text{어떤 샘플인가}}\Big).

문항당 샘플을 늘리면 두 번째 항만 준다. “이 벤치마크를 그대로 다시 돌리면 같은 숫자가 나올까?”를 묻는다면 두 번째 항만 해당되고, “이 모델이 이런 종류의 문제를 더 잘 푸는가?”를 묻는다면 둘 다 해당된다. AIME처럼 30문항짜리 벤치마크에서 문항별 풀이율이 표준편차 0.3으로 퍼져 있다면 그것만으로 se≈0.3/30≈5.5\mathrm{se} \approx 0.3/\sqrt{30} \approx 5.5 포인트다. 문항당 샘플을 아무리 늘려도 없어지지 않는다.

두 모델을 가르려면 문항이 몇 개 필요한가? 두 모델을 같은 문항으로 채점하고 문항별 차이 di=ai−bid_i = a_i - b_i를 분석하라: se=sd(d)/n\mathrm{se} = \mathrm{sd}(d)/\sqrt n. 쌍으로 묶으면 공통 난이도가 지워진다: Var(di)=Var(ai)+Var(bi)−2 Cov(ai,bi)\mathrm{Var}(d_i) = \mathrm{Var}(a_i) + \mathrm{Var}(b_i) - 2\,\mathrm{Cov}(a_i, b_i). 양측 α=0.05\alpha = 0.05, 검정력 80%로 참 차이 Δ\Delta를 검출하려면 Δ≥(1.96+0.84) se=2.8 se\Delta \ge (1.96 + 0.84)\,\mathrm{se} = 2.8\,\mathrm{se}, 즉

n  ≳  (2.8 σdΔ)2.n \;\gtrsim\; \Big(\frac{2.8\,\sigma_d}{\Delta}\Big)^2 .

정확도 70% 근처에서 오류가 독립이면(σd2=2⋅0.21\sigma_d^2 = 2\cdot 0.21) 2포인트 차이에 약 7.84×0.42/0.0004≈8,2007.84 \times 0.42/0.0004 \approx 8{,}200문항이 필요하다. 두 모델의 문항별 정오 상관이 0.5면 절반이 된다. 보고서 표에서 벤치마크 하나의 1–2포인트 차이는 대부분 잡음 안에 있다.

NumPy pass@k, 벤치마크 분산, 쌍 비교
import numpy as np
from math import comb
rng = np.random.default_rng(4)

def pass_at_k(n, c, k):
    """n개 중 c개 정답일 때 pass@k의 불편 추정량 (Chen et al., 2021), 안정한 곱 형태."""
    if n - c < k: return 1.0
    return 1.0 - np.prod(1.0 - k / np.arange(n - c + 1, n + 1))

n, k, p = 20, 5, 0.15                              # 문제당 샘플 20개, 샘플당 성공률 0.15
true = 1 - (1 - p) ** k
c = rng.binomial(n, p, size=200_000)
unb = np.array([pass_at_k(n, ci, k) for ci in range(n + 1)])[c.astype(np.intp)]
naive = 1 - (1 - c / n) ** k
print(f"pass@{k}, n={n}, p={p}: 참값 {true:.4f}   불편 {unb.mean():.4f}   순진한 plug-in {naive.mean():.4f}")
print(f"곱 형태 == 1 - C(n-c,k)/C(n,k): {np.isclose(pass_at_k(20, 3, 5), 1 - comb(17, 5) / comb(20, 5))}")

# 벤치마크 분산: 문항마다 난이도 p_i가 다르다; 문항당 K개 샘플
nq = 500
for K in [1, 4, 16]:
    pq = rng.beta(0.6, 0.6, size=(2000, nq))       # 실행마다 새 문항 집합
    total = (rng.binomial(K, pq) / K).mean(1)
    fixed = rng.beta(0.6, 0.6, size=nq)            # 고정된 문항 집합, 모델만 다시 실행
    rerun = (rng.binomial(K, fixed, size=(2000, nq)) / K).mean(1)
    th_tot = np.sqrt((pq.var() + np.mean(pq * (1 - pq)) / K) / nq)
    th_fix = np.sqrt(np.mean(fixed * (1 - fixed)) / K / nq)
    print(f"K={K:2d}: 새 문항 sd {total.std():.4f} (이론 {th_tot:.4f}) | 재실행 sd {rerun.std():.4f} (이론 {th_fix:.4f})")

# 같은 500문항 위의 두 모델: B가 모든 문항에서 약 3포인트 더 낫다
pa = rng.beta(0.6, 0.6, size=nq); pb = np.clip(pa + 0.03, 0, 1)
a = (rng.random((2000, nq)) < pa).astype(float); b = (rng.random((2000, nq)) < pb).astype(float)
gap = b.mean(1) - a.mean(1)
se_paired = (b - a).std(1, ddof=1) / np.sqrt(nq)
pa_hat, pb_hat = a.mean(1), b.mean(1)
se_naive = np.sqrt((pa_hat*(1-pa_hat) + pb_hat*(1-pb_hat)) / nq)
print(f"\n관측 차이의 평균 {gap.mean():.4f}, 실제 표준편차 {gap.std():.4f}")
print(f"  순진한 두 비율 se {se_naive.mean():.4f}   쌍 se sd(d_i)/sqrt(n) {se_paired.mean():.4f}")
print(f"  alpha=0.05 검정력: 순진 {np.mean(gap/se_naive > 1.96):.2f}   쌍 {np.mean(gap/se_paired > 1.96):.2f}")
 

순진한 두 비율 표준오차는 두 모델이 같은 문항을 푼다는 점을 무시해 잡음을 과대평가한다. 쌍 표준오차는 실제 퍼짐과 맞는다. 쌍으로 분석해도 500문항에서 3포인트 차이는 소수의 경우에만 검출된다. 여기서 검출 가능한 최소 차이는 약 2.8×0.024≈72.8 \times 0.024 \approx 7포인트다.

확인 문제Check yourself

문항 200개짜리 벤치마크에서 모델 정확도가 약 60%다. 95% 구간의 폭을 절반으로 줄이려면 문항이 대략 몇 개 필요한가?

반폭은 1.96p(1−p)/n1.96\sqrt{p(1-p)/n}, 1/n1/\sqrt n에 비례한다. 절반으로 줄이려면 문항이 44배, 800개 필요하다. (n=200n = 200에서 약 ±6.8\pm 6.8포인트, n=800n = 800에서 ±3.4\pm 3.4포인트.) 문항당 샘플을 늘리면 분산 중 문항 내부 부분만 줄고, 어떤 문항을 골랐느냐에서 오는 부분은 줄지 않는다.

확인 문제Check yourself

문제당 응답 10개를 뽑아 하나라도 맞으면 1점으로 pass@10을 추정했다. 이번에는 문제당 50개를 뽑아 c/50을 1 − (1 − p)^10에 대입했다. 옳은 것은?

정확히 n=k=10n = k = 10개면 “하나라도 맞음”이 불편 추정량이다(1−(10−c10)/(1010)1 - \binom{10-c}{10}/\binom{10}{10}은 c>0c > 0이면 1, 아니면 0). plug-in 1−(1−p^)101 - (1 - \hat p)^{10}은 불편인 p^\hat p에 볼록 사상 p↦(1−p)10p \mapsto (1-p)^{10}을 적용하므로 E[(1−p^)10]≥(1−p)10\mathbb{E}[(1-\hat p)^{10}] \ge (1-p)^{10}이고 pass@10을 과소추정한다. 50개를 뽑았다면 대신 1−(50−c10)/(5010)1 - \binom{50-c}{10}/\binom{50}{10}을 써라. 불편이고 10개짜리보다 분산이 작다.

정리

  • MSE = 편향² + 분산. 불편이 정확하다는 뜻은 아니다(Gaussian 분산에서는 n+1n+1로 나누는 것이 n−1n-1보다 낫다).
  • MLE는 ∑log⁡pθ(xi)\sum\log p_\theta(x_i)를 최대화 = cross-entropy를 최소화. p^=k/n\hat p = k/n, μ^=xˉ\hat\mu = \bar x, σ^2=1n∑(x−xˉ)2\hat\sigma^2 = \frac1n\sum(x-\bar x)^2. 점근 분산 1/(nI)1/(nI)이므로 se(p^)=p(1−p)/n\mathrm{se}(\hat p) = \sqrt{p(1-p)/n}.
  • CLT: xˉ±1.96 s/n\bar x \pm 1.96\,s/\sqrt n. 비율이 0이나 1 근처이거나 nn이 작으면 Wald보다 Wilson. 폭 ∝1/n\propto 1/\sqrt n.
  • Hoeffding: 어떤 nn에서든 P(∣xˉ−μ∣≥ε)≤2e−2nε2/(b−a)2P(|\bar x - \mu| \ge \varepsilon) \le 2e^{-2n\varepsilon^2/(b-a)^2}. 명제 KK개에 대한 union bound의 대가는 log⁡K\log K뿐이다.
  • 부트스트랩: 독립 단위를 복원추출하고, 복제값의 퍼짐이 표준오차다.
  • IS: Eπf=Eq[wf]\mathbb{E}_\pi f = \mathbb{E}_q[wf], ESS≈N/Eq[w2]\mathrm{ESS} \approx N/\mathbb{E}_q[w^2]. 시퀀스 가중치는 ESS/N≈e−Ts2\mathrm{ESS}/N \approx e^{-Ts^2}.
  • Control variate: f−c(h−Eh)f - c(h - \mathbb{E}h), c∗c^*에서 분산 (1−ρ2)Varf(1-\rho^2)\mathrm{Var}f. baseline과 k3k_3가 control variate다.
  • 평가: 불편 pass@k =1−(n−ck)/(nk)= 1 - \binom{n-c}{k}/\binom nk. 점수 분산 = (문항 분산 + 샘플링 분산/KK)/nn. 모델은 쌍 차이로 가르고 n≳(2.8σd/Δ)2n \gtrsim (2.8\sigma_d/\Delta)^2.

이 사이트에서 쓰이는 곳

더 읽을거리Further reading