#!/usr/bin/env python
from __future__ import print_function
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
mu = 50
sigma = 8
xv = mu + sigma*np.random.randn(10000)
# the histogram of the data
n, bins, patches = plt.hist(xv, 50, normed=1, facecolor='blue', alpha=0.65)
# add a density line
yline = mlab.normpdf( bins, mu, sigma)
l = plt.plot(bins, yline, 'r--', linewidth=2)
plt.xlabel('Smarts')
plt.ylabel('Probability')
plt.title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=50,\ \sigma=8$')
plt.axis([15, 85, 0, 0.06])
plt.grid(True)
No comments:
Post a Comment