In [1]:
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [2]:
x = arange(0,30)

In [4]:
x = x.reshape((30,1))

In [9]:
error = np.random.normal(0,15,(30,1))

In [10]:
y = 5*x+2+error

In [11]:
scatter(x,y)


Out[11]:
<matplotlib.collections.PathCollection at 0x8007c50>

In [12]:
A = hstack([x, ones_like(x)])

In [18]:
v = linalg.lstsq(A, y)[0]

In [20]:
plot(x,dot(A, v),"r")
scatter(x,y)


Out[20]:
<matplotlib.collections.PathCollection at 0x8450ac8>

In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]:


In [ ]: