Skip to content

Instantly share code, notes, and snippets.

@maluta
Created March 25, 2010 20:06
Show Gist options
  • Save maluta/344046 to your computer and use it in GitHub Desktop.
Save maluta/344046 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
from pylab import *
N = 100
start = 0
end = 1
A = rand()
B = rand()
x = linspace(start,end,N)
y = A*x + B
y += randn(N)/10
p = polyfit(x,y,1)
figure()
title('Regressao linear')
plot(x,y,'o',label='A=%.2f, B=%.2f' % (A,B))
plot(x,polyval(p,x),'-',label='A=%.2f, B=%.2f' % tuple(p))
legend(loc='best')
show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment