forum.alglib.net

ALGLIB forum
It is currently Sun Dec 22, 2024 2:16 pm

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: rep.errpar[0] returns 0 ?
PostPosted: Mon Sep 29, 2014 2:18 am 
Offline

Joined: Sun Sep 28, 2014 1:01 am
Posts: 3
Hello!

I'm really happy with how easy it seems to be to make nonlinear model fits using your library!
However, when I tried to compare the precision to "handmade" calibration for a few datapoints, I noticed that I don't get any parameter-errors! The covariance-matrix is also filled with 0. The state is 2, though, and the returned parameters seem to be nice.

I noticed this appears especially, if in theory I have more of a linear equation system than a fit: e.g. 3 points and 3 parameters.
However, the real solution is that one parameter is not contributing to the function-value!
e.g. I have datapoints like
Code:
real_2d_array x=[[1,0],[2,0],[3,0]];
real_1d_array y=[0,2.01,4];
real_1d_array c=[1,1,0];
real_1d_array cu=[1e8,1e8,0];
real_1d_array cd=[-1e8,1e8,0];

cu and cd are constraints to make the last parameter fixed.

Then I use your libary like in he examples:

Code:
double epsf = 0;
double epsx = 1e-10;
ae_int_t maxits = 0;
ae_int_t info;
lsfitstate state;
lsfitreport rep;
double diffstep = 1e-7;
int differentturns=0;

lsfitcreatef(x, y, c, diffstep, state);
lsfitsetcond(state, epsf, epsx, maxits);
lsfitsetbc(state, cd, cu);
alglib::lsfitfit(state, function_cx_1_func);
lsfitresults(state, info, c, rep);


with the function
Code:
    void function_cx_1_func(const real_1d_array &c, const real_1d_array &x, double &func, void *ptr)
{
   func = c[0]*pow(x[0]+c[1],2)/pow(1+c[2]*x[1],2);
}


As you can see, the solution would be c=[2,1,0].
This is also working, but rep.errpar[0] and so on is 0.
But how can it be 0 if there are 3 datapoints and effectively only 2 parameters to fit?
If I would add another datapoint, I would be given a parameter-error.

The only solution I currently see would be analyzing the data before fitting and reformatting x and c in case all x[i][1] would be 0.
But what would happen, if another parameter would get 0? I guess I won't get parameter-errors then either...

Is there anything I missed when using the alglib library or is this even a mathematical problem I'm not aware of? ^^


Top
 Profile  
 
 Post subject: Re: rep.errpar[0] returns 0 ?
PostPosted: Mon Sep 29, 2014 7:53 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
Hello!

Errors in parameters are reported only when number of data points is strictly greater than number of parameters. Furthermore, you won't get meaningful estimates with just 4 points - generally, number of points should be orders of magnitude larger than number of parameters to get accurate estimates. These are statistical estimates of error, not exact analytic ones, so they become accurate only when working with large samples (law of large numbers).

In you example these estimates should be just ignored.


Top
 Profile  
 
 Post subject: Re: rep.errpar[0] returns 0 ?
PostPosted: Thu Dec 18, 2014 7:18 am 
Offline

Joined: Thu Dec 18, 2014 7:11 am
Posts: 1
In you example these estimates should be just ignored.

_________________
kaleem


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 38 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group