help-gsl
[Top][All Lists]
Advanced

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

[Help-gsl] fitting convergence


From: Petr Ent
Subject: [Help-gsl] fitting convergence
Date: Tue, 05 Sep 2006 17:06:04 +0200 (CEST)

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);






reply via email to

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