Skip to content
DeepForgeby svx
All problems
HardStatisticsst-048

Bootstrap Mean CI (Percentile)

Problem

Draw n_boot bootstrap resamples of data with replacement using a self-contained Lehmer RNG seeded with seed (state = seed % 2147483647, next = state * 48271 % 2147483647), compute each resample mean, 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] for empty data or n_boot <= 0.

Hint

Sort the bootstrap means, then interpolate the two percentile ranks.

Test cases

case 1
in: [[1,2,3,4,5],200,7,0.05]
expected: [1.995,4.2]
case 2
in: [[5],50,1,0.1]
expected: [5,5]
case 3
in: [[],10,1,0.05]
expected: [0,0]
case 4
in: [[1,2],100,3,0.5]
expected: [1,2]
case 5
in: [[10,20,30,40],300,99,0.1]
expected: [17.5,32.5]
Starter codePython
def bootstrap_mean_ci(data, n_boot, seed, alpha):
    # Your code here
    pass

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