Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- u = [-2, 0, 2, 1, -1]
- y = [4, 6, 8, 7, 5]
- def theta(u,y):
- theta_licznik = 0
- theta_mianownik = 0
- for un, yn in zip(u,y):
- theta_licznik+=(yn*un)
- theta_mianownik+=un**2
- return theta_licznik/theta_mianownik
- plt.scatter(u,y)
- t = theta(u,y)
- y2=[]
- for el in u:
- y2.append(t*el)
- u, y2 = (list(x) for x in zip(*sorted(zip(u, y2))))
- plt.plot(u,y2)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement