from scipy.stats import norm def plot_pdf(mu,sigma,label,alpha=0.5,linestyle='k--',density=True): """ Plot 1-D data and its PDF curve. """ # Compute the mean and standard deviation of the data # Plot the data X = norm.rvs(mu, sigma, size=1000) plt.hist(X, bins=50, density=density, alpha=alpha,label=label) # Plot the PDF x = np.linspace(X.min(), X.max(), 1000) y = norm.pdf(x, mu, sigma) plt.plot(x, y, linestyle)