Lesson 15 of 15
Bootstrapping Returns
Bootstrapping Returns
Bootstrapping is a resampling technique to estimate the sampling distribution of a statistic without making distributional assumptions. It is essential in finance for constructing confidence intervals on Sharpe ratios, means, and other metrics.
The procedure:
- From a sample of values, draw values with replacement → bootstrap sample
- Compute the statistic of interest on this bootstrap sample
- Repeat times to get a bootstrap distribution
- Use percentiles of this distribution for confidence intervals
Bootstrap confidence interval at level (e.g., 0.05 for 95% CI):
- Lower bound: percentile of bootstrap distribution
- Upper bound: percentile
Use random.choices(xs, k=len(xs)) for sampling with replacement.
Your Task
Implement:
bootstrap_mean(xs, n_boot, seed)— list of bootstrap sample meansbootstrap_ci(xs, n_boot, seed, alpha=0.05)—(lower, upper)confidence interval
Python runtime loading...
Loading...
Click "Run" to execute your code.