Aan de slagGa gratis aan de slag

Change the standard deviation of normal distributions

You'll continue exploring the heights of American adult males, which you now know are normally distributed with a mean of 177 centimeters and a standard deviation of eight centimeters.

In this exercise, you'll also sample from a normal distribution and calculate the 95% confidence interval of the average height. But this time, you'll change the standard deviation to 15 without changing the mean of the heights. You'll explore what will happen to the mean and confidence interval of the average height if you perform the sampling again!

The following have been imported for you: random, NumPy as np, and SciPy's stats module as st.

Deze oefening maakt deel uit van de cursus

Monte Carlo Simulations in Python

Cursus bekijken

Oefeninstructies

  • Sample 1,000 times from the normal distribution where the mean is 177 and the standard deviation is 15; store the results inheights_177_15.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

random.seed(1231)
heights_177_8 = st.norm.rvs(loc=177, scale=8, size=1000)
print(np.mean(heights_177_8))
upper = np.quantile(heights_177_8, 0.975)
lower = np.quantile(heights_177_8, 0.025)
print([lower, upper])

# Sample 1,000 times from the normal distribution where the standard deviation is 15
heights_177_15 = ____
print(np.mean(heights_177_15))
upper = np.quantile(heights_177_15, 0.975)
lower = np.quantile(heights_177_15, 0.025)
print([lower, upper])
Code bewerken en uitvoeren