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

Connected

Exercise

Normal sampling distributions

You'd like to estimate a realistic mean closing price for the S&P 500 over a subset of its trading history. This seems like a natural application of a confidence interval, since you have a sample statistic and want to use it to estimate a population statistic. However, your first step should be to check if the sampling distribution is approximately normal. In this exercise, you'll do exactly that. In the next exercise, you'll use this result to create your confidence interval.

The same data btc_sp_df has been loaded for you, as have the packages pandas as pd, NumPy as np and Matplotlib as plt.

Instructions

100 XP
  • Define a variable num_samples as the desired number of samples (200), and define an empty list sample_means to store the mean from each of the 200 samples.
  • Write a for loop which will repeat the sampling process num_samples times.
  • Select 500 random S&P500 closing prices from the Close_SP500 column of btc_sp_df.
  • Compute the mean of each of these samples and store them in sample_means.