Bootstrap the Sampling Distribution

~15 mincode completion

Implement bootstrap_means(x, n_boot, seed) returning the 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

Where this shows up

~15 min

8 employers weight this skill

4 quant funds, 2 health and bio companies, 2 big tech firms. Top match scores 92.

Python
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
Loading docs…

The AI Mentor needs an account

It reads your code and the failing tests and nudges you toward the fix without handing you the answer. Free accounts get it on every problem you're working on today.