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: Benjamin Winkel
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 09:34:00 +0200
User-agent: Thunderbird 1.5.0.12 (X11/20070604)

Hi,

why would you want to use a nonlinear solver for a linear problem?

Cheers,
Benjamin

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...


--
Dipl.-Phys. Benjamin Winkel

Argelander Institute for Astronomy (AIfA)
University of Bonn
Auf dem Hügel 71, D-53121 Bonn, Germany

tel: +49 (0)228 73-3662
address@hidden
http://www.astro.uni-bonn.de/~bwinkel




reply via email to

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