PIXELBANKv9.1.0
Menu

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:

Input:
print(acc_ci(80, 100))
Output:
{'low': 0.7216, 'high': 0.8784, 'width': 0.1568}
Reasoning:
  • Calculate the sample accuracy pp by dividing the number of correct items by the total items: p=80/100=0.8p = 80 / 100 = 0.8.
  • Compute the standard error of the proportion using the formula p(1−p)n\sqrt{\frac{p(1-p)}{n}}: 0.8×0.2100=0.0016=0.04\sqrt{\frac{0.8 \times 0.2}{100}} = \sqrt{0.0016} = 0.04.
  • Determine the margin of error for a 95% confidence level by multiplying the standard error by the Z-score 1.961.96: 1.96×0.04=0.07841.96 \times 0.04 = 0.0784.
  • Calculate the raw lower and upper bounds by subtracting and adding the margin of error to the sample accuracy: low=0.8−0.0784=0.7216\text{low} = 0.8 - 0.0784 = 0.7216 and high=0.8+0.0784=0.8784\text{high} = 0.8 + 0.0784 = 0.8784.
  • Compute the width of the interval as the difference between the upper and lower bounds: 0.8784−0.7216=0.15680.8784 - 0.7216 = 0.1568.
  • 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.
🔒

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.