[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] locking parameters with multifit
From: |
mcdermott |
Subject: |
Re: [Help-gsl] locking parameters with multifit |
Date: |
Mon, 5 Jul 2004 17:45:37 +0100 |
Brian,
I finally figured out how to do this. The derivatives with respect to the
locked parameters must be set to zero and the initial values are set to the
desired locked values. For example, for a four-parameter logistic model, the
Jacobian would be defined as
int expb_df (const gsl_vector * x, void *params, gsl_matrix * J)
{
size_t n = ((struct data *)params)->n;
double *t = ((struct data *)params)->t;
double *locked = ((struct data *)params)->locked;
double a = gsl_vector_get (x, 0);
double b = gsl_vector_get (x, 1);
double c = gsl_vector_get (x, 2);
double d = gsl_vector_get (x, 3);
size_t i;
for (i = 0; i < n; i++)
{
/* Jacobian matrix J(i,j) = dfi / dxj, */
/* where fi = (Yi - yi), */
/* Yi = a+(b-a)/(1+(c/t)^d) */
/* and the xj are the parameters (a,b,c,d) */
double e = 1+pow(c/t[i],d);
if(locked[0] == 0) gsl_matrix_set (J, i, 0, 1-1/e);
else gsl_matrix_set (J, i, 0, 0);
if(locked[1] == 0) gsl_matrix_set (J, i, 1, 1/e);
else gsl_matrix_set (J, i, 1, 0);
if(locked[2] == 0) gsl_matrix_set (J, i, 2,
-(b-a)*pow(c/t[i],d-1)*(d/t[i])/pow(e,2));
else gsl_matrix_set (J, i, 2, 0);
if(locked[3] == 0) gsl_matrix_set (J, i, 3,
-(b-a)*pow(c/t[i],d)*log(c/t[i])/pow(e,2));
else gsl_matrix_set (J, i, 3, 0);
}
return GSL_SUCCESS;
}
where "locked" is a vector of zero's and one's.
Regards,
Jim
At Fri, 2 Jul 2004 14:21:09 +0100 , Brian Gough <address@hidden> wrote:
>address@hidden writes:
> > I am trying to adapt the GSL multifit code to allow the locking of
> > specific model parameters as required. A user-specified 0/1 vector
> > determines which parameters are unlocked/locked. Does anyone know
> > if this has ever been done? Thanks.
>
>You need to map the desired parameters into the vector used by the GSL
>routines.
>
>--
>Brian Gough
>
>Network Theory Ltd,
>Publishing Free Software Manuals --- http://www.network-theory.co.uk/
>
>