concept Sample Mean in category data

appears as: Sample Me
Data Science Bookcamp: Five Python Projects

This is an excerpt from Manning's book Data Science Bookcamp: Five Python Projects.

Listing 6.3. Visualizing sample means in a histogram
sample_means = frequencies
likelihoods, bin_edges, _ = plt.hist(sample_means, bins='auto',
                                     edgecolor='black', density=True)
plt.xlabel('Binned Sample Mean')
plt.ylabel('Relative Likelihood')
plt.show()
Listing 7.19. Plotting the distribution of 150k sampled means
np.random.seed(0)
sample_means = [np.random.choice(fish_lengths,
                                size=20,
                                replace=True).mean()
               for _ in range(150000)]
likelihoods, bin_edges, _ = plt.hist(sample_means, bins='auto',
                                      edgecolor='black', density=True)
plt.xlabel('Binned Sample Mean')
plt.ylabel('Relative Likelihood')
plt.show()