ComenzarEmpieza gratis

Calculating confidence intervals

Now that you've demonstrated that the sampling distribution for the closing price of the S&P 500 is approximately normally distributed, you'll compute a confidence interval! You want to estimate the mean closing price of the S&P 500, and calculating a confidence interval will do just that for you.

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

Este ejercicio forma parte del curso

Foundations of Inference in Python

Ver curso

Instrucciones del ejercicio

  • Select a random sample of 500 days from the column Close_SP500.
  • Calculate the mean of this random sample.
  • Calculate the standard error of this random sample as the standard deviation divided by the square root of the sample size.
  • Calculate a 95% confidence interval using the values you just calculated.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# Select a sample of 500 random days
sample_df = np.____(____, size=____)

# Calculate the mean of the sample
sample_mean = ____

# Calculate the standard error of the sample
sample_se = ____ / ____

# Calculate a 95% confidence interval using this data
stats.norm.interval(alpha=____,
                   loc=____,
                   scale=____)
Editar y ejecutar código