#Histogram of 10 000 random samples from the normal distribution
import numpy as np
import matplotlib.pyplot as plt
# the mean and the standard deviation
mu, sigma = 100.0, 8.0
samples = np.random.normal(loc=mu, scale=sigma, size=10000)
counts, bins, patches = plt.hist(samples , bins=100, density=True, color='skyblue', alpha=0.75,edgecolor='black')
plt.plot(bins, 1/(sigma * np.sqrt(2 * np.pi)) * np.exp( -(bins - mu)**2 / (2 * sigma**2) ), lw=2)
plt.title(r'$\mathrm{Histogram:}\ \mu=100,\ \sigma=15$')
plt.savefig("ex420.png", dpi=100)
plt.show()
Like this:
Like Loading...
Related
Recent Comments