1import matplotlib.pyplot as plt
2import numpy as np
3
4mu, sigma = 0.5, 0.1
5s = np.random.normal(mu, sigma, 1000)
6
7# Create the bins and histogram
8count, bins, ignored = plt.hist(s, 20, density=True) # density is used in matplotlib 3.1 v and ahead
9# if using matplotlib v2.1 use normed instead of density
10
11# Plot the distribution curve
12plt.plot(bins, 1/(sigma * np.sqrt(2 * np.pi)) *
13 np.exp( - (bins - mu)**2 / (2 * sigma**2) ), linewidth=3, color='y')
14plt.show()