Contents
Key concepts
Bayes' rule and base rates
P(A|B) = P(B|A)·P(A) / P(B), with P(B) expanded over all ways B can happen. When the prior is small, even an accurate test produces mostly false positives (base-rate neglect). The odds form is the fastest to compute: posterior odds = prior odds × likelihood ratio, where LR⁺ = sensitivity / false-positive rate.
Estimation: MLE, MAP and bias
MLE maximises the likelihood; for a Gaussian it gives the sample mean and a variance estimate with divisor n, which is biased low by a factor (n−1)/n (hence ddof=1). MAP adds a log-prior: an isotropic Gaussian prior on weights is L2 regularisation with λ = σ²/τ², and a Laplace prior gives L1. Cross-entropy loss is negative log-likelihood under a categorical or Bernoulli model.
Standard deviation, standard error and the CLT
SD describes spread of individual observations and does not shrink with n. The standard error of a mean is σ/√n; for a proportion it is √(p(1−p)/n). By the central limit theorem the mean is approximately normal, so a 95% CI is estimate ± 1.96 SE. Quadrupling n only halves the SE. The approximation breaks down on small evals: below a few hundred items, such as a 30-problem maths set, CLT intervals usually understate uncertainty and can spill outside [0, 1] or shrink to zero width at 0% or 100%, so use Wilson, exact or Bayesian (Beta) intervals, or a bootstrap.
Hypothesis tests, power and minimum detectable effect
α is the false-positive rate you accept under the null; power (1−β) is the probability of detecting a true effect of a given size. Per-arm sample size for two proportions is roughly n ≈ (z₁₋α/₂ + z₁₋β)² · [p₁(1−p₁) + p₂(1−p₂)] / δ²; with α = 0.05 two-sided and 80% power the multiplier is (1.96 + 0.84)² ≈ 7.85. Halving the detectable effect quadruples n.
Paired designs and variance reduction
Comparing two models on the same eval items, or the same users before and after, removes between-item variance: use McNemar’s test or a paired bootstrap on per-item differences. CUPED regresses the outcome on a pre-experiment covariate; Microsoft reported about 50% variance reduction at Bing, equivalent to doubling traffic. Clustered standard errors are needed when items share a passage or users share a session. For stochastic models and agents, run several trials per item: the intraclass correlation splits variance into between-item difficulty and within-item inconsistency, and one 2025 study found it settled after 8–16 trials on structured tasks but needed 32 or more on complex reasoning tasks. With n samples per task of which c pass, the unbiased pass@k estimate is 1 − C(n−c, k)/C(n, k); plugging p̂ into 1 − (1 − p̂)^k is biased low, because that function is concave in p.
CalculatorPass@k versus pass^k at fixed k
- Pass@k
- 98.4%
- Pass^k
- 42.2%
Pass@k = 1 − (1 − True per-trial success rate) ^ Trials k = 98.4%
Pass^k = True per-trial success rate ^ Trials k = 42.2%
| Case | True per-trial success rate | Trials k | Pass@k | Pass^k |
|---|---|---|---|---|
| Default | 0.75 | 3 | 98.4% | 42.2% |
Peeking, multiple comparisons and sequential testing
Stopping as soon as p < 0.05 inflates the false-positive rate well above 5% (Evan Miller shows ten peeks turn a nominal 1% into about 5%). Valid options: a fixed horizon, group-sequential designs with alpha spending, always-valid p-values (mSPRT), or Bayesian decision rules stated in advance. Testing many metrics or slices needs Bonferroni or false-discovery-rate control.
Entropy, cross-entropy and KL divergence
H(p) = −Σ p log p; cross-entropy H(p,q) = −Σ p log q = H(p) + KL(p‖q). Because H(p) of the data is fixed, minimising cross-entropy equals minimising KL from data to model, which is MLE. KL is asymmetric and non-negative; forward KL is mass-covering, reverse KL mode-seeking, which matters for distillation and RLHF penalties. The ELBO is log p(x) minus KL(q(z|x) ‖ p(z|x)).
Linear algebra and calculus for learning
Symmetric real matrices have real eigenvalues and orthogonal eigenvectors (covariance → PCA). SVD A = UΣVᵀ exists for any matrix and truncation gives the best rank-r approximation (Eckart–Young); a rank-r update to a d×d matrix needs 2dr parameters, which is LoRA’s saving. The gradient of softmax cross-entropy with respect to logits is p − y; reverse-mode autodiff gets all gradients of a scalar loss for a small constant multiple of one forward pass. Orthogonalisation is now examinable too: the Muon optimiser replaces a weight matrix’s momentum update G = USVᵀ with UVᵀ, the nearest semi-orthogonal matrix, computed with about five Newton–Schulz matrix iterations instead of an SVD, so every singular direction gets a step of the same size.
Worked examples
Base rates: how likely is a positive test to be a true positive?
A condition has prevalence 1 in 1,000. A test has 99% sensitivity and a 2% false-positive rate. A random person tests positive. What is P(condition | positive)? What if a second, independent test is also positive?
Bayes’ rule
P(+) = 0.99 × 0.001 + 0.02 × 0.999 = 0.00099 + 0.01998 = 0.02097
P(D | +) = 0.00099 / 0.02097 ≈ 4.7%
Natural frequencies (the intuition interviewers want): of 100,000 people, 100 have the condition and 99 test positive; of 99,900 without it, about 1,998 test positive. Only 99 of 2,097 positives are real.
Second independent positive (odds form):
- prior odds now 0.0472 / 0.9528 ≈ 0.0496
- LR⁺ = 0.99 / 0.02 = 49.5
- posterior odds ≈ 0.0496 × 49.5 ≈ 2.45 → probability 2.45 / 3.45 ≈ 71%
Caveat: real repeat tests are rarely independent (same biology, same lab), so 71% is an upper bound. The same arithmetic applies to fraud alerts or a classifier flagging rare policy violations.
Sample size for an A/B test on conversion
Baseline conversion is 10%. How many users per arm do you need to detect an absolute lift to 11% with a two-sided α = 0.05 and 80% power? What would halve it?
z₁₋α/₂ = 1.96, z₁₋β = 0.84 → (1.96 + 0.84)² ≈ 7.85
Variance term: p₁(1−p₁) + p₂(1−p₂) = 0.10 × 0.90 + 0.11 × 0.89 = 0.0900 + 0.0979 = 0.1879
δ² = 0.01² = 0.0001
n ≈ 7.85 × 0.1879 / 0.0001 ≈ 14,750 users per arm (about 29,500 total).
Levers:
- CUPED / regression adjustment: a 50% variance reduction roughly halves n.
- Larger MDE: detecting +2 points instead of +1 cuts n by about 4×.
- More sensitive metric: e.g. add-to-basket instead of purchase, if it is a validated proxy.
- One-sided test only if you would genuinely never act on a negative result. Then convert n into days of traffic and run whole weeks to cover weekly seasonality.
Is 84% versus 81% on a 200-item eval real?
A new prompt scores 84% and the old one 81% on the same 200 items. Test it unpaired and paired, assuming the new prompt fixes 14 items the old one got wrong and breaks 8 it got right. How many items would an unpaired comparison need for 80% power?
Unpaired (wrong analysis for shared items, but the usual first instinct):
- SE(84%) = √(0.84 × 0.16 / 200) ≈ 0.026; SE(81%) ≈ 0.028
- SE of the difference = √(0.026² + 0.028²) ≈ 0.038
- z = 0.03 / 0.038 ≈ 0.79 → p ≈ 0.43. Not distinguishable.
Paired (McNemar): only the 22 discordant items carry information.
- χ² = (14 − 8)² / (14 + 8) = 36 / 22 ≈ 1.64 → p ≈ 0.20 (exact binomial p ≈ 0.29). Still noise.
Items needed unpaired at 80% power: n ≈ 7.85 × (0.81 × 0.19 + 0.84 × 0.16) / 0.03² = 7.85 × 0.2883 / 0.0009 ≈ 2,500 per arm.
Paired with an 11% discordance rate needs roughly (1.96·√0.11 + 0.84·√(0.11 − 0.0009))² / 0.03² ≈ 960 items, a 2.6× saving. Also sample each item several times to separate model sampling noise from item difficulty.
What changed recently
Muon's orthogonalised updates reach frontier pre-training
DeepSeek-V4, a pair of mixture-of-experts models with million-token context (the larger has 1.6T parameters), was trained with the Muon optimiser for faster convergence and more stable training, following Moonshot’s 2025 result that Muon scales with roughly twice AdamW’s compute efficiency. Muon’s update is the orthogonal polar factor UVᵀ of the momentum matrix, approximated by Newton–Schulz iterations. Research interviewers now use it to test SVD, polar-decomposition and matrix-iteration intuition.
pass@k versus pass^k becomes standard agent-eval vocabulary
Anthropic’s guide to agent evals defines pass@k as the chance of at least one success in k trials and pass^k as the chance that all k succeed, so the first rises with k while the second falls (0.75³ ≈ 42%). It recommends multiple trials per task because outputs vary between runs. Interviewers now ask which metric suits a product (one-shot coding tool versus customer-facing agent) and how to estimate each.
Intraclass correlation for run-to-run variance in agent evals
A December 2025 paper argued that single-run accuracy hides agent inconsistency and proposed the intraclass correlation to separate between-query variance (difficulty) from within-query variance (inconsistency), reporting values of about 0.30–0.77 on GAIA. It found the estimate stabilised after 8–16 trials on structured tasks but needed 32 or more on complex reasoning. It gives a concrete answer to “how many reruns per task do you need?”
Signal-to-noise ratio as a benchmark-selection criterion
Heineman et al. defined a benchmark’s signal (how well it separates stronger from weaker models) and noise (variability between training checkpoints), and showed across 30 benchmarks and 375 models that a higher ratio makes small-scale decisions more reliable and lowers scaling-law prediction error. Cheap fixes include scoring with perplexity rather than accuracy, dropping noisy subtasks and averaging checkpoints. Interviewers use it to probe whether you can reason about measurement noise before trusting a small-model ablation.
Normal-approximation error bars fail on small LLM evals
An ICML 2025 spotlight position paper argued that CLT-based intervals, fine for benchmarks with thousands of items, dramatically understate uncertainty on small specialised ones, and recommended simple frequentist and Bayesian alternatives with a supporting library. With reasoning benchmarks such as 30-problem maths sets now headline numbers, candidates are expected to know which interval to use and why.
Pitfalls
- Confusing SD with SE, reporting a CI that ignores that eval items are clustered by source document, or putting a normal-approximation interval on a 30-item benchmark.
- Reading a p-value as the probability the null is true, or a non-significant result as proof of no effect.
- Stopping an A/B test the first time p < 0.05, or slicing until something is significant.
- Using unpaired tests for two models scored on the same items, throwing away most of the power.
- Claiming deep-network training loss is convex, or that eigenvectors of any square matrix are orthogonal.
- Forgetting that the MLE of variance divides by n and is biased; the unbiased estimator uses n − 1.
How interviewers probe it
- Mental arithmetic under time pressure: base-rate problems, binomial mean and variance, quick power calculations.
- Derivations: MLE of a Gaussian, L2 as a Gaussian prior, softmax cross-entropy gradient, the ELBO.
- Applied judgement: ‘our metric moved 0.8 points, ship it?’ — seeds, CIs, paired tests, equal tuning budgets.
- Experiment design follow-ups: peeking, sequential tests, CUPED, multiple metrics and guardrails.
- Linear algebra intuition: what PCA keeps, why SVD truncation is optimal, why low-rank adapters work, and what Muon’s orthogonalised update does to the singular values.
- Agent and LLM eval statistics: pass@k versus pass^k under independence, the unbiased pass@k estimator from n samples, how many trials per task you need, and why a 30-question benchmark needs a different interval.
Quiz
Three questions from this guide. Answer each in your head or out loud, show the model answer, then rate yourself. The cards join your practice deck and come back when they are due.
A test for a condition with prevalence 1 in 1,000 has 99% sensitivity and a 2% false-positive rate. Someone picked at random tests positive. Roughly how likely are they to have the condition? Explain the intuition.
Model answer, written in a candidate's voice
- Bayes: P(D|+) = 0.990.001 / (0.990.001 + 0.02*0.999) ≈ 0.00099/0.02097 ≈ 4.7%.
- Natural frequencies: out of 100,000, ~100 have the condition, ~99 test positive; ~99,900 do not, ~1,998 false-positive; 99/2,097 ≈ 4.7%.
- This is base-rate neglect: the low prevalence means false positives outnumber true positives.
- A second independent positive multiplies odds by LR+ ≈ 0.99/0.02 ≈ 49.5, moving the estimate to roughly 71%, not certainty.
0.2% of transactions are fraudulent. A detector flags 95% of fraud and 2% of legitimate transactions. What fraction of flagged transactions are fraud? What does this imply for alert design?
Model answer, written in a candidate's voice
- Bayes: P(fraud|flag)=0.950.002/(0.950.002+0.02*0.998)≈0.087.
- Low base rate means most flagged transactions are false positives despite 95% fraud recall.
- Report precision at the operating point alongside catch rate; do not equate high recall with high precision.
- Use step-up authentication or review for borderline alerts; reserve hard declines for high-confidence cases.
- Set thresholds by cost of false declines vs missed fraud, and track precision/recall/cost rather than catch rate alone.
- Base rates differ by segment, so compute precision per segment rather than one global figure.
Baseline conversion is 10%. How many users per arm do you need to detect a 1-percentage-point lift at α=0.05 and 80% power? What levers reduce it?
Model answer, written in a candidate's voice
- n ≈ 14.7k per arm under two-sided α=0.05, 80% power, equal allocation, independent users.
- Formula: n ≈ (z1-α/2 + z1-β)^2 [p1(1-p1)+p2(1-p2)] / δ^2 ≈ (1.96+0.84)^2 (0.09+0.0979)/0.0001 ≈ 14.7k.
- Levers: variance reduction (CUPED), a more sensitive/lower-noise metric, a larger MDE, one-sided test only if pre-specified and justified.
- Trade-off: larger n means longer duration and more drift/novelty risk; aggressive levers can shorten the test but may miss smaller lifts or depend on assumptions.
You have finished this topic.
Reading
- Seeing TheoryInteractive visual refresher on probability, distributions, frequentist and Bayesian inference.
- How Not To Run an A/B TestShort, numeric explanation of why peeking inflates false positives.
- Mathematics for Machine LearningFree book; read the linear algebra, matrix decomposition, vector calculus and probability chapters.
- The Matrix Calculus You Need For Deep LearningBuilds Jacobians and the chain rule for vectors step by step, exactly what derivation questions need.
- Adding Error Bars to Evals: A Statistical Approach to Language Model EvaluationsApplies standard errors, paired comparisons and power analysis to LLM evals.
- Position: Don't Use the CLT in LLM Evals With Fewer Than a Few Hundred DatapointsICML 2025 spotlight showing why normal-approximation error bars are too narrow on small benchmarks, with frequentist and Bayesian alternatives.
- Improving the Sensitivity of Online Controlled Experiments by Utilizing Pre-Experiment Data (CUPED)The original variance-reduction method behind most experimentation platforms.
- Always Valid Inference: Bringing Sequential Analysis to A/B TestingFormal treatment of peeking-safe p-values and confidence intervals (mSPRT).
Practise this topic
- A test for a condition with prevalence 1 in 1,000 has 99% sensitivity and a 2% false-positive rate. Someone picked at random tests positive. Roughly how likely are they to have the condition? Explain the intuition.
- 0.2% of transactions are fraudulent. A detector flags 95% of fraud and 2% of legitimate transactions. What fraction of flagged transactions are fraud? What does this imply for alert design?
- Baseline conversion is 10%. How many users per arm do you need to detect a 1-percentage-point lift at α=0.05 and 80% power? What levers reduce it?
- A PM checks the dashboard daily and stops when p < 0.05. What is wrong, and what valid alternatives exist?
- Your new prompt scores 84% against 81% on a 200-item set. Is that real? How many items would you need?
- Your method beats the baseline by 0.8 points on a benchmark. What would you need to see before believing the improvement is real?
- Explain the difference between a sample’s standard deviation and the standard error of the mean, and how each changes with sample size.
- Define entropy, cross-entropy and KL divergence for discrete distributions, show how they relate, and explain why minimising cross-entropy loss equals maximum likelihood. Why is KL asymmetric, and when does the direction matter?
- Define linear independence and matrix rank. If a fine-tuning update to a d×d weight matrix is constrained to rank r, how many parameters does it use, and what does that constraint assume about the update?
- Derive the gradient of cross-entropy loss with respect to the logits when predictions come from a softmax. How do you implement the loss so it never overflows or underflows?