Estimate a dataset mean and a percentile confidence interval by bootstrap resampling. For each of B resamples, draw N observations with replacement and compute:
xˉ∗(b)=N1i=1∑Nxi∗(b)For confidence level c, set α=(1−c)/2 and use the α and 1−α quantiles of the bootstrap means. Here, N is the dataset size and b indexes a resample. Use seed to initialize np.random.default_rng. Return bootstrap_mean, lower, and upper as Python floats in a dictionary.
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}
Create an index matrix with rng.integers(0, x.size, size=(n_bootstrap, x.size)).
Take x[indices].mean(axis=1) before applying np.quantile.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number
Accepts: number
Estimate a dataset mean and a percentile confidence interval by bootstrap resampling. For each of B resamples, draw N observations with replacement and compute:
xˉ∗(b)=N1i=1∑Nxi∗(b)For confidence level c, set α=(1−c)/2 and use the α and 1−α quantiles of the bootstrap means. Here, N is the dataset size and b indexes a resample. Use seed to initialize np.random.default_rng. Return bootstrap_mean, lower, and upper as Python floats in a dictionary.
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}
Create an index matrix with rng.integers(0, x.size, size=(n_bootstrap, x.size)).
Take x[indices].mean(axis=1) before applying np.quantile.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Accepts: number
Accepts: number