In [1]:
from scipy.stats import norm
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
import numpy as np
import scipy as sp
import random

In [2]:
# read data from a text file. One number per line
n=1000
random_y1= random.sample(xrange(1), n)
random_y2= random.sample(xrange(1), n)
random_x1= random.sample(xrange(1), n)
random_x2= random.sample(xrange(1), n)
datos=[sp. ]


  File "<ipython-input-2-d81fbe49a902>", line 7
    datos=[sp. ]
               ^
SyntaxError: invalid syntax

In [ ]:
# best fit of data
(mu, sigma) = norm.fit(datos)

# the histogram of the data
n, bins, patches = plt.hist(datos, 60, normed=1, facecolor='green', alpha=0.75)

# add a 'best fit' line
y = mlab.normpdf( bins, mu, sigma)
l = plt.plot(bins, y, 'r--', linewidth=2)

#plot
plt.xlabel('Smarts')
plt.ylabel('Probability')
plt.title(r'$\mathrm{Histogram\ of\ IQ:}\ \mu=%.3f,\ \sigma=%.3f$' %(mu, sigma))
plt.grid(True)

plt.show()