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
.
This exercise is part of the course
Monte Carlo Simulations in Python
Exercise instructions
- Sample 1,000 times from the normal distribution where the mean is 177 and the standard deviation is 15; store the results in
heights_177_15
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
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])