LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

NonLinearFitWithWeight does not erturn error if maximum number of iterations is exceeded

Solved!
Go to solution

Hello NI,

 

I would appreciate some feedback on my claim having found a bug in the NonLinearFitWithWeight routine.

 

I have provided one (out of several) examples where the routine fails, and uploaded a simple code demonstrating this failure. All that is required is to run the code and, using the debugger, examine the value of maximum_iterations.

 

Thanks!

0 Kudos
Message 11 of 15
(1,939 Views)

 

Hi Wolfgang,

 

We have investigated the specific case you have provided.

 

This is the expected behavior with current algorithm. You can trust the fitting results if no error is reported. And if you look at the squared_error you will find the difference is extremely small when the maximum number of iterations is greater than or equal to 4.

 

I can tell you more details about why this happens if you are interested. And we are considering whether we need to improve the algorithm for this kind of cases.

 

Thanks,
xearthl

Message Edited by xearthl on 05-06-2010 02:41 AM
0 Kudos
Message 12 of 15
(1,936 Views)

Ah, great, a sign of life 🙂 Thanks!

 

Yes, of course I am interested 🙂

 

As mentioned, I have found other cases (with more complex functions), where I can permit 1000 or 2000 iterations, and the fitting routine returns with exactly 1000 or 2000 iterations. Obviously, the improvements achieved in these iterations are marginal.

 

What I have learned is that 'solution' in the help does not necessarily mean convergence. It appears to mean very slow convergence, close to a solution.

 

YES, I would be very much interested to find better alogrihms in CVI! I already started to consider implementing the LM algorithm myself, using the free C implementation of the  Levenberg-Marquardt nonlinear least squares algorithms (http://www.ics.forth.gr/~lourakis/levmar/). Unfortunately, in this case I would loose the benefit of optimized code.

Message 13 of 15
(1,931 Views)
Solution
Accepted by topic author Wolfgang

In our algorithm, one of the prerequisite for terminating the iteration at the n-th step is that the residue decreases in two successive steps, that is, residue in the n-th step is smaller than that in the (n-1)-th step and the residue in the (n-1)-th step is smaller than that in the (n-2)-th step.  So when the residue is jumping up and down we will not stop our efforts to find a better result until we reach the maximum number of iterations.


Meanwhile we will double check the fitting results at the end of the algorithm. And we will not report an error when we find the difference between minimum residue and the last residue is extremely small.

 

Thanks,

xearthl

Message 14 of 15
(1,904 Views)

Thanks,

 

your description matches my observations 🙂 After all, I would suggest a slightly more elaborate explanation in the help

0 Kudos
Message 15 of 15
(1,895 Views)