1. Learn
  2. /
  3. Courses
  4. /
  5. Foundations of Inference in Python

Exercise

Bootstrap confidence intervals

You previously saw that there is some degree of correlation between the S&P 500 and Bitcoin. One way to measure this would be to look at the correlation coefficient Pearson's R between the two. However, doing so results in only a point estimate. Presumably, at some points in time the correlation between the two is quite close, while at other times they behave very differently. How can you characterize the variability? One approach is to create a bootstrap confidence interval for the correlation coefficient between the two. That's precisely what you'll do now!

A DataFrame of S&P 500 and Bitcoin prices (btc_sp_df) has been loaded for you, as have the packages pandas as pd, NumPy as np, and stats from SciPy.

Instructions 1/2

undefined XP
    1
    2
  • Compute the daily percent change of BTC and SP500; use the console to see the columns needed.
  • Write a function which computes Pearson's R and only returns R (not the p-value).
  • Form a bootstrap confidence interval using this function.