This is my first post here. Here's my issue:
I have been given this distribution of heights for an entire population (random seed generated):
seed(47)
pop_heights = norm.rvs(172, 5, size=50000)
_ = plt.hist(pop_heights, bins=30)
_ = plt.xlabel('height (cm)')
_ = plt.ylabel('number of people')
_ = plt.title('Distribution of heights in entire town population')
_ = plt.axvline(172, color='r')
_ = plt.axvline(172+5, color='r', linestyle='--')
_ = plt.axvline(172-5, color='r', linestyle='--')
_ = plt.axvline(172+10, color='r', linestyle='-.')
_ = plt.axvline(172-10, color='r', linestyle='-.')
Then, a function to sample 10 random heights from the population was defined, and called daily sample:
def townsfolk_sampler(n):
return np.random.choice(pop_heights, n)
seed(47)
daily_sample1 = townsfolk_sampler(10)
np.mean(daily_sample1)
And I have now been tasked with:
"Q8: Simulate performing this random trial every day for a year, calculating the mean of each daily sample of 10, and plot the resultant sampling distribution of the mean."
I am looking for the proper method to write this function. Thank you in advance!
Aucun commentaire:
Enregistrer un commentaire