Skip to content
DeepForgeby svx
All problems

Statistical Significance Bootstrap

Problem

Compute a seeded bootstrap confidence interval for the mean.

With rng = random.Random(seed), draw n_resamples bootstrap samples of the same size as scores using rng.randrange(n), average each, sort the means, and return [means[int(0.025 * n_resamples)], means[int(0.975 * n_resamples)]]. An empty input returns [0.0, 0.0].

Hint

Bootstrapping builds the sampling distribution of the mean by resampling with replacement.

Test cases

case 1
in: [[1,2,3,4,5],200,0]
expected: [1.8,4.4]
case 2
in: [[0.5,0.5],100,7]
expected: [0.5,0.5]
case 3
in: [[],50,0]
expected: [0,0]
case 4
in: [[10],50,42]
expected: [10,10]
Starter codePython
import random
def bootstrap_ci(scores, n_resamples, seed):
    # Your code here
    pass

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