help-gsl
[Top][All Lists]
Advanced

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

Re: [Help-gsl] GSL 1.9: Levenberg-Marquardt non-linear fit with selected


From: O. Hartmann
Subject: Re: [Help-gsl] GSL 1.9: Levenberg-Marquardt non-linear fit with selected invariant coefficients not to be fit, HOWTO?
Date: Tue, 07 Aug 2007 11:04:10 +0000
User-agent: Thunderbird 2.0.0.6 (X11/20070803)

Oliver Jennrich wrote:
On 8/1/07, O. Hartmann <address@hidden> wrote:
Hello,

while using GSL the first time (coming from some Numerical Recipes in C
code pieces) I ran into trouble solving a non-linear least square problem.
The problem ist simple, not to say trivial, some points need to get
fitted in the usual way. The modell-function is a polynomial expression
of degree 15 with 16 coefficients (a_0 - a_15) and in most cases we only
fit the first coefficient, the constant (a_0). Sometimes we need to
select some other coefficients to be fitted for making the polynomial
fitting the dataset.
Well, The Numerical Recipes code offers an elegant method using a 'mask'
for each coefficient, if the corresponding switch in the mask (the mask
represents the amount of coefficients) is set to 'false' or 0, the
coefficient does not get touched and fitted, if set to else, the
coefficient is handled as usual and gets fitted. These operations are
done while preparing the covariant matrix.
The GSL routines, as shown in the example in chapter 37: Nonlinear
Least-Square Fitting seems not to offer a simple 'switch' to do the same
as mentioned above. Does anyone do have a hint?

Well, you can pass whatever data you want to the function through the
'data'  parameter. It is declared 'void'  so you are responsible to
extract the right data. Define a struct

 struct data {
       size_t n;
       double * y;
       int * mask;  /* 1 or 0 */
     };

and use the 'mask'  to multiply the coefficients...


The mask is used to setup the Jacobian marix; each coefficient that is marked '1' get's a derivation, others stay zero.

I solved the problem; sometimes someone has to look behind the maths. unsolved is the problem how to shrink down the coabvraince matrix (and therefore the Jacobian) if only one coefficient is about to be fitted. Compared to the Numerical Recipes introduced method someone is able to have one measurement for one coefficient of the specified polynomial. Using GSL, at a first look someone need as many measurement data (rows) as coefficients are present, no matter whether they get fit or not. Hope I can go around this ...

Thanks for your answers,

Regards
Oliver




reply via email to

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