'Fitting gaussianlike model to data does not work?
I want to fit this data.
I have the following model function.
def losvd_param(v, v_rot, v_disp, h3, h4):
y = np.asarray((np.asarray(v)-v_rot)/(v_disp)) # define new variably y for compact notation
return (np.exp(-0.5 * y**2) * (1 + h3*((2*np.sqrt(2)*y**3-3*np.sqrt(2)*y)/np.sqrt(6)) + h4*((4*y**4-12*y**2+3)/np.sqrt(24))))
The 4 parameters refer to: x-value of maximum, width of the distribution, skewness and kurtosis.
I use curve_fit() to fit my data:
gh_moments = curve_fit(losvd_param, vel_corr_peak, broadening_func)[0]
and get the unexpected output [1. 1. 1. 1.] which is clearly not correct it should more be something like [1318, 300, 0, 0], putting these values in mannually into my model function I roughly get the right fit to my data. I also get the warning:
OptimizeWarning: Covariance of the parameters could not be estimated
Can anybody tell me why this could be the case ? Edit: I get the same results, when I use a different model function simple gaussian. Using a linear model I get the fit is "working", so it might be something connected to the gaussian function ? (Note that my x-array goes from values rougly 500-2250)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

