Skip to content

Instantly share code, notes, and snippets.

@APN-Pucky
Created November 7, 2019 20:19
Show Gist options
  • Save APN-Pucky/b19d86e170cd848f8b99ed5fc41a6e08 to your computer and use it in GitHub Desktop.
Save APN-Pucky/b19d86e170cd848f8b99ed5fc41a6e08 to your computer and use it in GitHub Desktop.
from scipy.odr import *
def fit_curve(datax,datay,function,p0=None,yerr=None,xerr=None):
model = Model(lambda p,x : function(x,*p))
realdata = RealData(datax,datay,sx=xerr,sy=yerr)
odr = ODR(realdata,model,beta0=p0)
out = odr.run()
return unp.uarray(out.beta,out.sd_beta)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment