TensorTonicTensorTonic
Problems
Study PlansProjectsNewInterviewPricingFeedback
Problems
Loading...
1 / 1

Bootstrap Mean & Confidence Interval

Probability and Statistics
Medium

Estimate a dataset mean and a percentile confidence interval by bootstrap resampling. For each of BBB resamples, draw NNN observations with replacement and compute:

xˉ∗(b)=1N∑i=1Nxi∗(b)\bar{x}^{*(b)}=\frac{1}{N}\sum_{i=1}^{N}x_i^{*(b)}xˉ∗(b)=N1​i=1∑N​xi∗(b)​

For confidence level ccc, set α=(1−c)/2\alpha=(1-c)/2α=(1−c)/2 and use the α\alphaα and 1−α1-\alpha1−α quantiles of the bootstrap means. Here, NNN is the dataset size and bbb indexes a resample. Use seed to initialize np.random.default_rng. Return bootstrap_mean, lower, and upper as Python floats in a dictionary.

Loading visualization...

Examples

Input: x = [1.0, 2.0, 3.0, 4.0], n_bootstrap = 1000, ci = 0.9, seed = 42

Output: {"bootstrap_mean": 2.497, "lower": 1.5, "upper": 3.5}

Explanation: The seeded resamples form a reproducible distribution of 1,000 sample means.

Input: x = [5.0], n_bootstrap = 100, ci = 0.95, seed = 123

Output: {"bootstrap_mean": 5, "lower": 5, "upper": 5}

Hint 1

Create an index matrix with rng.integers(0, x.size, size=(n_bootstrap, x.size)).

Hint 2

Take x[indices].mean(axis=1) before applying np.quantile.

Requirements

  • Draw every bootstrap sample with replacement
  • Generate all resample indices from np.random.default_rng(seed)
  • Compute percentile bounds for the requested confidence level
  • Return exactly bootstrap_mean, lower, and upper in a dictionary

Constraints

  • x is a nonempty one-dimensional numeric list
  • n_bootstrap is positive and 0 < ci < 1
  • Use NumPy only
Try Similar Problems
Sample Var StdMean Median ModePercentilesT Test One SampleChi2 Independence

Sign in to take notes on this problem

Case 1
Case 2

Accepts: array

Accepts: number

Accepts: number

Accepts: number

You must run your code first.
PrevNext

Bootstrap Mean & Confidence Interval

Probability and Statistics
Medium

Estimate a dataset mean and a percentile confidence interval by bootstrap resampling. For each of BBB resamples, draw NNN observations with replacement and compute:

xˉ∗(b)=1N∑i=1Nxi∗(b)\bar{x}^{*(b)}=\frac{1}{N}\sum_{i=1}^{N}x_i^{*(b)}xˉ∗(b)=N1​i=1∑N​xi∗(b)​

For confidence level ccc, set α=(1−c)/2\alpha=(1-c)/2α=(1−c)/2 and use the α\alphaα and 1−α1-\alpha1−α quantiles of the bootstrap means. Here, NNN is the dataset size and bbb indexes a resample. Use seed to initialize np.random.default_rng. Return bootstrap_mean, lower, and upper as Python floats in a dictionary.

Loading visualization...

Examples

Input: x = [1.0, 2.0, 3.0, 4.0], n_bootstrap = 1000, ci = 0.9, seed = 42

Output: {"bootstrap_mean": 2.497, "lower": 1.5, "upper": 3.5}

Explanation: The seeded resamples form a reproducible distribution of 1,000 sample means.

Input: x = [5.0], n_bootstrap = 100, ci = 0.95, seed = 123

Output: {"bootstrap_mean": 5, "lower": 5, "upper": 5}

Hint 1

Create an index matrix with rng.integers(0, x.size, size=(n_bootstrap, x.size)).

Hint 2

Take x[indices].mean(axis=1) before applying np.quantile.

Requirements

  • Draw every bootstrap sample with replacement
  • Generate all resample indices from np.random.default_rng(seed)
  • Compute percentile bounds for the requested confidence level
  • Return exactly bootstrap_mean, lower, and upper in a dictionary

Constraints

  • x is a nonempty one-dimensional numeric list
  • n_bootstrap is positive and 0 < ci < 1
  • Use NumPy only
Try Similar Problems
Sample Var StdMean Median ModePercentilesT Test One SampleChi2 Independence

Sign in to take notes on this problem

Case 1
Case 2

Accepts: array

Accepts: number

Accepts: number

Accepts: number

You must run your code first.