0

Hello guys I have used "curve_fit()" to fit my data to voigt function in the following way:

def voigt(x,a,m,s,g):
    z = (x-m+complex(0,g))/(s*math.sqrt(2))
    d = wofz(z)
    return (a*d.real)/(s*math.sqrt(2*pi))

popt, pcov = curve_fit(voigt, xval, yval, bounds=([0,25,0,0.012], [99,37., 0.01, 2.5]), maxfev =10000)

I need to calculate how god is my fit with the data I obtained, How can I achieve this?

Kanan Yagublu
  • 119
  • 3
  • 11
  • from the [docs](https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.curve_fit.html) to calculate 1 std on the parameters use ```perr = np.sqrt(np.diag(pcov))``` – Nin17 Aug 16 '22 at 09:14
  • Okay, I see, the better fit is if I have lower values for it right? – Kanan Yagublu Aug 16 '22 at 13:02
  • Yes, lower errors mean better confidence in these parameters. If you want to judge the entire fit, you can use R-squared, see https://stackoverflow.com/a/30804603/8310295. – K.Cl Aug 18 '22 at 00:56

0 Answers0