Hi!
I want to fit a three-Gaussian model on a given data (download-link: http://sharesend.com/6yhykztt).
I’ve tried different inital Number to get the fit to converge. Either the left peak doesn’t converge or the peak in the middle doesn’t converge.
Would be grateful if somebody has some hint or solution for this problem!
Best regards,
Tohu
data = Import["$path/data.txt", "Table"];
Block[{$DisplayFunction = Identity},
dataPlot =
ListPlot[data, PlotStyle -> {AbsolutePointSize[4], Hue[.7]},
PlotRange -> {{0, 400}, {0, 65000}}];
];
Show[dataPlot]
model = (amp1 E^(-((-mu1 + x)^2/(2 sigma1^2)))) + (amp2 E^(-((-mu2 +
x)^2/(2 sigma2^2)))) + (amp3 E^(-((-mu3 +
x)^2/(2 sigma3^2))));
vars = {{amp1, 63000}, {mu1, 100}, {sigma1, 8}, {amp2, 6000}, {mu2,
210}, {sigma2}, {amp3, 40000}, {mu3, 310}, {sigma3}};
cons = And @@ Thread[{amp1, sigma1, amp2, sigma2, amp3, sigma3} > 0];
fit = NonlinearModelFit[data, {model, cons}, vars, x,
MaxIterations -> 100]
Show[Plot[fit[x], {x, 0, 500}, PlotRange -> All,
PlotStyle -> {Thick, Red}],
ListPlot[data, PlotStyle -> Opacity[0.5]]]
fit["ParameterTable"]



