Bootstrap the Sampling Distribution
Implement bootstrap_means(x, n_boot, seed) returning the B resample means as an array of length n_boot.
Seed first with , then draw each resample with as index positions. The exact call order matters, because the tests compare against a specific seeded run.
Examples
Four resamples of a four-point sample, seeded at 0
- Input
- bootstrap_means([1, 2, 3, 4], 4, 0)
- Output
- [2, 4, 2.75, 2.25]
A constant sample cannot move, however you resample it
- Input
- bootstrap_means([5, 5, 5], 3, 1)
- Output
- [5, 5, 5]
Hints
Hint 1
Loop a fixed number of times and update the running value each pass.
Hint 2
Watch for this: samples without replacement.
Requirements
x: the observed sample, shape (n,)n_boot: how many resamples to draw: passed to np.random.seed before drawing anything
Return array of shape (n_boot,) of resample means
Constraints
Allowed library: NumPy only
Time limit: 200 ms, Memory: 64 MB
Try similar problems(4)
Where this shows up
8 employers weight this skill
4 quant funds, 2 health and bio companies, 2 big tech firms. Top match scores 92.
import numpy as np
def bootstrap_means(x, n_boot, seed):
"""
Means of n_boot bootstrap resamples.
Args:
x: the observed sample, shape (n,)
n_boot: how many resamples to draw
seed: passed to np.random.seed before drawing anything
Returns:
array of shape (n_boot,) of resample means
"""
# YOUR CODE HERE
pass