Bootstrap Confidence Interval Width for Eval Accuracy
Problem Statement
Report the normal-approximation 95% confidence interval for an agent's eval accuracy, so a small benchmark's noise is visible.
Background
For n graded items with k correct, the sample accuracy is p = k/n. The Wald 95% interval is *p +/- 1.96 * sqrt(p(1-p)/n)**, clamped to [0, 1]. Report the lower bound, upper bound, and width.
Your Task
def acc_ci(k, n):
Return a dict {"low": float, "high": float, "width": float}, each rounded to 4 decimals.
Input Format
- k (int correct), n (int total, >= 1).
Output Format
- A dict of three floats.
Sample
print(acc_ci(80, 100))
Output:
{'low': 0.7216, 'high': 0.8784, 'width': 0.1568}
Example
print(acc_ci(80, 100))
{'low': 0.7216, 'high': 0.8784, 'width': 0.1568}- Calculate the sample accuracy by dividing the number of correct items by the total items: .
- Compute the standard error of the proportion using the formula : .
- Determine the margin of error for a 95% confidence level by multiplying the standard error by the Z-score : .
- Calculate the raw lower and upper bounds by subtracting and adding the margin of error to the sample accuracy: and .
- Compute the width of the interval as the difference between the upper and lower bounds: .
- The final output is
{'low': 0.7216, 'high': 0.8784, 'width': 0.1568}
Constraints
p = k/n; margin= 1.96*sqrt(p*(1-p)/n).- Clamp low/high to
[0,1]; width = high - low. - Round each to 4 decimals.