Skip to content
DeepForgeby svx
All problems
HardStatisticsst-257

Bootstrap CI for Eval Accuracy

Problem

Seed random with seed, draw n_boot bootstrap resamples of the 0/1 outcomes with replacement, and return the percentile interval [low, high] at alpha/2 and 1 - alpha/2 using linear interpolation between closest ranks. Return [0.0, 0.0] when outcomes is empty, n_boot <= 0, or alpha lies outside (0, 1).

Hint

Resample indices with int(random.random() * n) using the seeded global RNG.

Test cases

case 1
in: [[1,1,0,1,0,1,1,0],2000,42,0.05]
expected: [0.25,1]
case 2
in: [[1,0],500,7,0.1]
expected: [0,1]
case 3
in: [[],100,1,0.05]
expected: [0,0]
case 4
in: [[1,1,1],100,3,0.2]
expected: [1,1]
Starter codePython
import random
def bootstrap_accuracy_ci(outcomes, n_boot, seed, alpha):
    # Your code here
    pass

4 test cases · run your code against them in the editor