import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import norm
# generate 1000 instances of a normal random variable
mean, sigma = 0, 1
sample = norm.rvs(mean, sigma, size=1000)
# a 50-bin histogram of the sample
plt.hist(sample, 50, normed=1, facecolor='white')
# the population distribution
range = np.arange(-5, 5, 0.001)
plt.plot(range, norm.pdf(range, mean, sigma), color='red', linewidth=4)
plt.show()
Result:
No comments:
Post a Comment