help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gsl] fitting convergence


From: John Gehman
Subject: Re: [Help-gsl] fitting convergence
Date: Wed, 06 Sep 2006 10:48:07 +1000

Assuming your initial values for your floating parameters are reasonable, perhaps double check the partial derivatives with respect to each of those parameters -- that's where I usually slip up.

For your function, I get

partial(y)/partial(Ai) = ( 1 - exp(-x/ti) )
partial(y)/partial(ti) = -Ai*x*exp(-x/ti) / ti^2
partial(y)/partial(Ap) = ( 1 - exp(-x/tp) )
partial(y)/partial(tp) = -Ap*x*exp(-x/tp) / tp^2

without trying them I don't guarantee that they're correct (as I said, that's usually where I slip up), but perhaps this will point you in the right direction. The signs of the second and fourth partial derivatives are tedious, and a likely source of error. Obviously you have to adapt this notation into your Fit_df function, making sure to order the partials' indices according to the order of the parameters in the vector of floats.

Good Luck
john

---------------------------------------------------------

Dr John Gehman (address@hidden)
Research Fellow; Separovic Lab
School of Chemistry
University of Melbourne (Australia)


On 06/09/2006, at 1:06 AM, Petr Ent wrote:

hello,
I would like to fit data to following equation using non-lineat least squares fitting. I am using real life data (not generated from equation), but I have pretty good idea about final results and I use it as seed values (starting values which you provide to the solver). but whatever I do, solver does not converge.

equation:
y = fo + Ai * ( 1 - exp(-x/ti) ) + Ap * ( 1 - exp(-x/tp) )

where Ai, ti, Ap, tp are parameters, fo is constant. shape of the function should be +- logarithmic, parameters should be similar to
Ai = 800
ti = 6
Ap = 200
tp = 15

I use modified non-linear least squares fitting example.
I tried to fit same source data using logarithmic and square-root models
y = a * log (b * x) + c
y = a * sqrt(b * x) + c
and both of them converged and results are good.

If anyone has any clue, why the first model does not converge, or what i am doing wrong, I would appreciate it.
regards Petr Ent

this is method where I use GSL to fitting

const gsl_multifit_fdfsolver_type *T;
gsl_multifit_fdfsolver *s;

int iter = 0;

gsl_multifit_function_fdf f;

double x_init[maxVars];
for (unsigned i = 0; i < configData[k].seeds.size(); i++)
{
   x_init[i] = configData[k].seeds[i];
}

gsl_vector_view x = gsl_vector_view_array (x_init, fitData.paramCount);

//Fit_... functions do what they are supposed to do, counting value and derivations //fitData is structure with all the info about fitting - data, number of parameters, data length, ...
f.f = &Fit_f;
f.df = &Fit_df;
f.fdf = &Fit_fdf;
f.n = fitData.n;
f.p = fitData.paramCount;
f.params = &fitData;

T = gsl_multifit_fdfsolver_lmsder;
s = gsl_multifit_fdfsolver_alloc (T, fitData.n, fFunc->paramCount);

gsl_multifit_fdfsolver_set (s, &f, &x.vector);

do
{
   iter++;
   status = gsl_multifit_fdfsolver_iterate (s);

   if (status)
   {
      break;
   }
   status = gsl_multifit_test_delta (s->dx, s->x,0,1e-2);
}
while (status == GSL_CONTINUE && iter < 500);




_______________________________________________
Help-gsl mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/help-gsl



reply via email to

[Prev in Thread] Current Thread [Next in Thread]