Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = np.array([-1.93,-1.43,-1.21,-1.62,-1.57,-1.13,
- -1.21,-0.76,-1.93,-1.41,-2.31,-2.83,
- -1.74,-2.05,-2.22,-1.24,-2.13,-2.55,
- -1.3,-0.44,-0.99,-1.79,-0.97])
- y = np.array([1.87,2.29,2.66,2.42,2.52,2.18,
- 2.3,2.49,2.04,2.35,2.12,1.88,
- 1.87,2.08,1.67,2.44,1.91,1.85,
- 2.42,2.67,2.11,1.81,2.4])
- c, resids, rank, singvals, rcond = np.polyfit(x, y, 1, full=True)
- p = np.poly1d(c)
- print('linear fit: {!s}'.format(p))
- xv = np.linspace(-3, 0, 50)
- yv = p(xv)
- plt.clf()
- plt.plot(xv, yv, 'k-', x, y, 'ro', ms=5, lw=1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement