I want to fit a curve to some data using curve_fit in scipy. After I searched for the syntax I found this,
import numpy as np
from scipy.optimize import curve_fit
def func(x, a, b, c):
return a * np.exp(-b * x) + c
xdata = np.linspace(0, 4, 50)
y = func(xdata, 2.5, 1.3, 0.5)
ydata = y + 0.2 * np.random.normal(size=len(xdata))
popt, pcov = curve_fit(func, xdata, ydata)
But the documentation is not really clear, specially regarding the parameters of the function func, I know x is the numpy array of independent variable values, but what are a, b, and c? Also, what does this line mean,
a * np.exp(-b * x) + c
to calculate y we call func with the independent variables and other parameters, but what is ydata? And why do we calculate it this way,
ydata = y + 0.2 * np.random.normal(size=len(xdata))
One last thing, if I get the fitted model (the equation) by scipy inside some function, how can I use it in another one?
Any help is appreciated. Thanks.

