Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. from numpy import *
  2. from scipy.optimize import curve_fit
  3.  
  4. def func(x, a, b, c):
  5. return a*exp(-(x-b)**2/(2*c**2))
  6. file = loadtxt("angdist1.xvg", skiprows = 18, dtype = float)
  7. x = []
  8. y = []
  9. for i in range(shape(file)[0]):
  10. x.append(file[i,0])
  11. y.append(file[i,1])
  12.  
  13. popt, pcov = curve_fit(func, x, y)
  14.  
  15. plt.plot(x, func(x, *popt), color = 'red', linewidth=2)
  16. plt.legend(['Original','fitting'], loc=0)
  17. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement