Drawing conclusions from samples
You've seen how random sampling can be used to choose a sample of data which is (hopefully!) representative of the population you are studying. You've also seen how bias in sampling procedure can result in conclusions that are suspect at best, and completely wrong at worst.
In this exercise you'll analyze the average closing price of the S&P 500. If you take two different samples of trading days and compute confidence intervals for each, should you expect to see the same result? It's time for you to dive in and see!
This exercise is part of the course
Foundations of Inference in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Sample 1: Select a random sample of 500 rows
sample_df = ____.sample(n=____)
# Compute a 95% confidence interval for the closing price of SP500
sample_ci = stats.____.____(alpha=____,
loc=____.mean(),
scale=____.std()/np.sqrt(____))
print(sample_ci)