Fitting data with a exponentially modified gaussian equation

Hello,
I am using curve fitting tool box and I am trying to fit below equation of the exponentially modified gaussian distribution. I have attached my attempt at fittin the PDF, I have also attached my x and y data along with this question. Please help me with the solution. Thanks very much!
(c/2) * (exp((c^2*sg^2)/2)) * exp(-c*(x-mu)) * erf((1/sqrt(2)) * ((c*sg) - ((x-mu)/sg)))

Réponses (1)

Matt J
Matt J le 18 Mar 2022
Modifié(e) : Matt J le 18 Mar 2022
Because you are using a custom model, you need to supply an initial guess of the parameters under "Fit Options". Otherwise, the toolbox will choose one at random (which will probably be bad).

5 commentaires

Sanchit Sharma
Sanchit Sharma le 18 Mar 2022
Modifié(e) : Sanchit Sharma le 18 Mar 2022
Could you please help me with figuring out what could be the initial guess. I have never fitted a ExGauss function.
Plot the function for values of mu, c and sb and compare with your data curve.
This will give you a feeling about the form of the curve and a good starting guess.
Are you sure that the integral from -oo to oo will be 1 for all choices of mu, c and sg as is necessary for a pdf ?
Plot the function for values of mu, c and sb and compare with your data curve.
Or, compute the fitting error for different combinations of mu,c, sg. You can do a grid search on, say, a 15x15x15 grid of mu,c,sg, values. Once you find the best fit from the grid search, you can use that as your starting guess in a more formal fit.
Is your function a probability density function ?
If yes, try
omega = 800.0;
zeta = 7500;
alpha = -1.3;
f = @(x) 2/(omega*sqrt(2*pi))*exp(-((x-zeta).^2/(2*omega^2)))*0.5.*(1+erf(alpha*(x-zeta)/omega));
x = 7000-1500:0.01:7000+1000;
plot(x,f(x))
But your .png file seems to indicate that the area under your curve is not equal to 1. So I assume you are not dealing with a pdf. In this case, the above function f is not suitable.
It vaguely looks like the data comes from a histogram, but it was not normalized to have unit area under the curve.
trapz(x,y)
ans =
73.2481

Connectez-vous pour commenter.

Catégories

En savoir plus sur Get Started with Curve Fitting Toolbox dans Centre d'aide et File Exchange

Produits

Version

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by