I have a data set and a kernel density estimate for those data. I believe the KDE should be reasonably well described by an exponentinally modified Gaussian, so I'm trying to sample from the KDE and fit those samples with a function of that type. However, when I try to fit using scipy.optimize.curve_fit, my fit doesn't match the data well at all. My code is
import scipy.special as sse
from scipy.optimize import curve_fit
def fit_func(x, l, s, m):
return 0.5*l*n.exp(0.5*l*(2*m+l*s*s-2*x))*sse.erfc((m+l*s*s-x)/(n.sqrt(2)*s)) # exponential gaussian
popt, pcov = curve_fit(fit_func, n.linspace(0,1,100), data)
My "data set" (from sampling my KDE) is
data = [1.00733940e-09, 1.36882036e-08, 1.44555907e-07, 1.18647634e-06, 7.56926695e-06, 3.75417381e-05, 1.44836578e-04, 4.35259159e-04, 1.02249858e-03, 1.89480681e-03, 2.83