I do not understand what's wrong with this data fitting:
from scipy.optimize import curve_fit def sin_fit(x, *p): a,b,c,d= p return a + b*np.sin(c*x+ d) # p0 is the initial guess for the fitting coefficients p0 = [0.1, 1., 1., 0.1] coeff, var_matrix = curve_fit(sin_fit, t, data, p0=p0) I guess either there is something obvious wrong, which I am missing at the moment, or I cannot use the curve fit from scipy for this problem. Any ideas?


data = 10 + 3*np.sin(t + 1.)