python - What curve_fit to use in scipy for this dataset? -
i trying fit curve set of data points:
def func(x, a, b, c): return * np.log(-b * x) + c #return * np.exp(-b * x) + c xdata = np.array(x) ydata = np.array(y) popt, pcov = curve_fit(func, xdata, ydata) plt.scatter(xdata, ydata, label='data') plt.plot(xdata, func(xdata, *popt), 'r', label='fit') plt.xlabel('x') plt.ylabel('y') plt.legend() plt.show()
the data set contains 50 points. 2 of them outliers. generated 2 plots of data , fitted curve: first 1 contains outliers , other plot excludes outliers:
however, both curve fits contain many nan values, why red fitted line small. got values of 1 each variable in popt
. tried both log
, exp
fits seen in code above
are there better curves exponential or log fits can try?
edit: definition of func comes before curve_fit call
Comments
Post a Comment