Appendix H. Statistical Methods for Agent Evaluation
Use these methods when your evaluation involves Bayesian estimates, repeated looks at results, multiple comparisons, or data that call for non-parametric analysis. Chapter 2 covers the frequentist methods used for the core examples.
H.1 Bayesian Evaluation
H.1.1 Beta-Binomial Model for Binary Metrics
For binary success/failure metrics, let \(\theta\) be the true success probability. With prior \(\theta \sim \text{Beta}(\alpha, \beta)\) and \(s\) successes in \(n\) trials:
Posterior: \[p(\theta \mid s, n) = \text{Beta}(\alpha + s,\; \beta + n - s).\]
Posterior mean: \[\mathbb{E}[\theta \mid s, n] = \frac{\alpha + s}{\alpha + \beta + n}.\]
Credible interval: The \((1-\gamma)\) central credible interval is \([q_{\gamma/2},\; q_{1-\gamma/2}]\) where \(q_p\) is the \(p\)-th quantile of \(\text{Beta}(\alpha+s,\; \beta+n-s)\).
H.1.2 Bayesian A/B Testing for Agent Comparison
To compare two agents \(A\) and \(B\) with success probabilities \(\theta_A\) and \(\theta_B\):
Priors: \(\theta_A \sim \text{Beta}(\alpha_A, \beta_A)\), \(\theta_B \sim \text{Beta}(\alpha_B, \beta_B)\), independent.
Posterior probability of superiority: \[P(\theta_A > \theta_B \mid D_A, D_B) = \int_0^1 \int_0^{\theta_A} p(\theta_A \mid D_A) p(\theta_B \mid D_B) \, d\theta_B \, d\theta_A.\]
Compute by Monte Carlo: draw \(S\) samples \(\theta_A^{(s)} \sim p(\theta_A \mid D_A)\), \(\theta_B^{(s)} \sim p(\theta_B \mid D_B)\), then estimate \(\widehat{P(\theta_A > \theta_B)} = \frac{1}{S}\sum_{s=1}^{S} \mathbb{I}\{\theta_A^{(s)} > \theta_B^{(s)}\}\).
Decision rule: Ship agent \(A\) over \(B\) if \(P(\theta_A > \theta_B \mid D) > 1 - \gamma\) (e.g., \(\gamma = 0.05\)).
H.1.3 Hierarchical Models for Multi-Task Evaluation
For \(K\) task slices: \[\theta_k \sim \text{Beta}(\alpha, \beta), \qquad s_k \mid \theta_k \sim \text{Binomial}(n_k, \theta_k).\]
Hyperparameters \((\alpha, \beta)\) estimated from all slices (empirical Bayes). Slice estimates shrink toward the global mean.
Posterior for slice \(k\): \[p(\theta_k \mid s_k, n_k, \hat{\alpha}, \hat{\beta}) = \text{Beta}(\hat{\alpha} + s_k,\; \hat{\beta} + n_k - s_k).\]
H.2 Sequential Testing and Early Stopping
H.2.1 Sequential Probability Ratio Test (SPRT)
Test \(H_0: \theta = \theta_0\) vs. \(H_1: \theta = \theta_1\) for Bernoulli metric. After \(n\) observations with \(s\) successes:
Log likelihood ratio: \[\Lambda_n = s \log\frac{\theta_1}{\theta_0} + (n-s) \log\frac{1-\theta_1}{1-\theta_0}.\]
Stopping rule: Continue while \(B < \Lambda_n < A\), where \(A = \log\frac{1-\beta}{\alpha}\), \(B = \log\frac{\beta}{1-\alpha}\). Accept \(H_1\) if \(\Lambda_n \geq A\); accept \(H_0\) if \(\Lambda_n \leq B\).
H.2.2 Alpha Spending for Continuous Monitoring
At looks \(t_1 < t_2 < \dots < t_K\), an alpha-spending function \(\alpha(t)\) allocates total error budget \(\alpha\).
O’Brien-Fleming: \(\alpha(t) = 2\left[1 - \Phi\left(\frac{z_{\alpha/2}}{\sqrt{t/T}}\right)\right]\).
Pocock: \(\alpha_k = 1 - (1-\alpha)^{1/K}\) at each look.
Reject at look \(k\) if \(p_k \leq \alpha(t_k) - \alpha(t_{k-1})\).
H.3 Multiple-Comparison Control
Without correction, with \(m\) independent tests at level \(\alpha\), P(at least one false positive) \(= 1 - (1-\alpha)^m\).
H.3.1 Bonferroni Correction
Reject \(H_{(i)}\) only if \(p_{(i)} \leq \alpha/m\). Controls FWER at \(\leq \alpha\); conservative when tests are correlated.
H.3.2 Benjamini–Hochberg (BH) FDR Control
- Sort \(p\)-values: \(p_{(1)} \leq \dots \leq p_{(m)}\).
- Find largest \(k\) such that \(p_{(k)} \leq \frac{k}{m} q\).
- Reject \(H_{(1)}, \dots, H_{(k)}\).
Controls \(\text{FDR} = \mathbb{E}[V/(R \vee 1)] \leq q\).
H.3.3 Holm–Bonferroni Step-Down
- Sort \(p\)-values: \(p_{(1)} \leq \dots \leq p_{(m)}\).
- Find smallest \(k\) such that \(p_{(k)} > \frac{\alpha}{m - k + 1}\).
- Reject \(H_{(1)}, \dots, H_{(k-1)}\); do not reject \(H_{(k)}, \dots, H_{(m)}\).
Holm is uniformly more powerful than Bonferroni while controlling FWER.
H.4 Non-Parametric Methods
H.4.1 Mann–Whitney U Test
For samples \(X_1, \dots, X_m\) and \(Y_1, \dots, Y_n\): \[U = \sum_{i=1}^{m}\sum_{j=1}^{n} \mathbb{I}\{X_i > Y_j\} + \frac{1}{2}\sum_{i=1}^{m}\sum_{j=1}^{n} \mathbb{I}\{X_i = Y_j\}.\]
Under \(H_0\): \(\mathbb{E}[U] = mn/2\), \(\text{Var}(U) = mn(m+n+1)/12\).
H.4.2 Wilcoxon Signed-Rank Test
For paired differences \(D_i = X_i - Y_i\): \[W^+ = \sum_{i: D_i > 0} R_i\] where \(R_i\) is the rank of \(|D_i|\). Normal approximation for \(n \geq 10\).
H.4.3 Bootstrap Confidence Intervals
For metric \(\hat{\theta} = g(\tau_1, \dots, \tau_N)\): 1. Draw \(B\) bootstrap samples by resampling with replacement. 2. Compute \(\hat{\theta}^*_b\) for each. 3. Percentile CI: \([\hat{\theta}^*_{(\alpha/2)},\; \hat{\theta}^*_{(1-\alpha/2)}]\).
BCa intervals recommended for small samples.
H.5 Sample Size and Power
For paired comparison with effect \(\delta = \theta_A - \theta_B\) and SD \(\sigma_d\): \[N \approx \left(\frac{z_{1-\alpha/2} + z_{1-\beta}}{\delta / \sigma_d}\right)^2.\]
Stratified version: \[N \approx \frac{(z_{1-\alpha/2} + z_{1-\beta})^2 \sum_k p_k^2 \sigma_k^2}{\delta^2}.\]
H.6 Notation Summary
| Symbol | Meaning |
|---|---|
| \(\theta\) | True parameter |
| \(\Lambda_n\) | Log likelihood ratio |
| \(A, B\) | SPRT boundaries |
| \(\alpha(t)\) | Alpha-spending function |
| \(p_{(i)}\) | Ordered \(p\)-values |
| \(q\) | Target FDR level |
| \(U\) | Mann–Whitney statistic |
| \(W^+\) | Wilcoxon statistic |
| \(B\) | Bootstrap resamples |
| \(\delta\) | Effect size |
| \(\sigma_d\) | SD of paired differences |
Further Reading
- Gelman et al., Bayesian Data Analysis [1].
- Jennison & Turnbull, Group Sequential Methods [2].
- Benjamini & Hochberg, “Controlling the False Discovery Rate” [3].
- Efron & Tibshirani, An Introduction to the Bootstrap [4].
- Lehmann & Romano, Testing Statistical Hypotheses [5].