daily pastebin goal
34%
SHARE
TWEET

linfit example

murison Feb 19th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. x = np.array([-1.93,-1.43,-1.21,-1.62,-1.57,-1.13,
  2.               -1.21,-0.76,-1.93,-1.41,-2.31,-2.83,
  3.               -1.74,-2.05,-2.22,-1.24,-2.13,-2.55,
  4.               -1.3,-0.44,-0.99,-1.79,-0.97])
  5. y = np.array([1.87,2.29,2.66,2.42,2.52,2.18,
  6.               2.3,2.49,2.04,2.35,2.12,1.88,
  7.               1.87,2.08,1.67,2.44,1.91,1.85,
  8.               2.42,2.67,2.11,1.81,2.4])
  9. c, resids, rank, singvals, rcond = np.polyfit(x, y, 1, full=True)
  10. p = np.poly1d(c)
  11. print('linear fit: {!s}'.format(p))
  12. xv = np.linspace(-3, 0, 50)
  13. yv = p(xv)
  14. plt.clf()
  15. plt.plot(xv, yv, 'k-', x, y, 'ro', ms=5, lw=1);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top