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.
Diese Übung ist Teil des Kurses
Foundations of Inference in Python
Anleitung zur Übung
- Define a variable 
num_samplesas the desired number of samples (200), and define an empty listsample_meansto store the mean from each of the 200 samples. - Write a 
forloop which will repeat the sampling processnum_samplestimes. - Select 500 random S&P500 closing prices from the 
Close_SP500column ofbtc_sp_df. - Compute the mean of each of these samples and store them in 
sample_means. 
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Define the number of samples to take and store the sample means
num_samples = ____
sample_means = ____
# Write a for loop which repeats the sampling num_samples times
for i in ____:
  # Select 500 random Close_SP500 prices 
  sp500_sample = np.___(____, size=____)
  # Compute mean closing price and save it to sample_means
  ____.append(____.mean())
    
plt.hist(sample_means)
plt.show()