dediggefedde
09-08-2014, 03:55 PM
Hello!
I used the mrqmin function from the second c-edition to fit the function
y=a0 (b-b0)^2 / (1+c*c0)^2
my sample-data are triplets: (a,b,y)
Currently I use the mrqmin-function like this:
for(int i=0;i<3e6;i++){
mrqmin(x, y, sig, NPCalib, a,ia,3, covar, alpha, &chisk, afunc, &alamda);
if(chisk<0.0001)sumchisk++;
if(sumchisk>5)break;
if(alamda>1e5)alamda=100;
}
Here I actually fit only y=a0 (b-b0)^2 while the c0-part comes into play within afunc:
void afunc(int i, double x[],double a[], double *y, double dyda[], int ma)
{
*y=a[1]*pow(x[i]+a[2],2)/pow(1+a[3]*Ct[i-1],2);
dyda[1]= pow(x[i] + a[2],2)/pow(1 + a[3]*Ct[i-1],2);
dyda[2]= (2*a[1]*(x[i] + a[2]))/pow(1 + a[3]*Ct[i-1],2);
dyda[3]= (-2*a[1]*Ct[i-1]*pow(x[i] + a[2],2))/pow(1 + a[3]*Ct[i-1],3);
}
For that I changed the sets of parameters so it also gives the index i. the global Variable Ct provides the c values.
However, I noticed the fit is often failing or mostly wrong...
is there a better method for fitting this problem or am I doing it wrong?
Edit: yeah... I saw that it had to be put to ch 15 now... But I can't move/delete this post, so, please, someone could be so kind to move it? ^^
I used the mrqmin function from the second c-edition to fit the function
y=a0 (b-b0)^2 / (1+c*c0)^2
my sample-data are triplets: (a,b,y)
Currently I use the mrqmin-function like this:
for(int i=0;i<3e6;i++){
mrqmin(x, y, sig, NPCalib, a,ia,3, covar, alpha, &chisk, afunc, &alamda);
if(chisk<0.0001)sumchisk++;
if(sumchisk>5)break;
if(alamda>1e5)alamda=100;
}
Here I actually fit only y=a0 (b-b0)^2 while the c0-part comes into play within afunc:
void afunc(int i, double x[],double a[], double *y, double dyda[], int ma)
{
*y=a[1]*pow(x[i]+a[2],2)/pow(1+a[3]*Ct[i-1],2);
dyda[1]= pow(x[i] + a[2],2)/pow(1 + a[3]*Ct[i-1],2);
dyda[2]= (2*a[1]*(x[i] + a[2]))/pow(1 + a[3]*Ct[i-1],2);
dyda[3]= (-2*a[1]*Ct[i-1]*pow(x[i] + a[2],2))/pow(1 + a[3]*Ct[i-1],3);
}
For that I changed the sets of parameters so it also gives the index i. the global Variable Ct provides the c values.
However, I noticed the fit is often failing or mostly wrong...
is there a better method for fitting this problem or am I doing it wrong?
Edit: yeah... I saw that it had to be put to ch 15 now... But I can't move/delete this post, so, please, someone could be so kind to move it? ^^