LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

levenberg

Solved!
Go to solution

I can't get the LM fitting routine to work.  Attached is a simple program that fails with the message

 

Error -20003 occurred at NI_Gmath.lvlib:LM get new coefficients.vi:1380001

Possible reason(s):
Analysis:  The number of samples must be > 0.

 

The supplied example (fit to 3 Gaussians) runs just fine, and if I'm not doing the same thing as that example, the difference is too subtle for me.

 

Any help appreciated.

Download All
0 Kudos
Message 1 of 9
(3,190 Views)
Solution
Accepted by gnunesjr

Why is every single VI (front panel and block diagram!) maximised to the screen??? Very annoying!

 

Your partial derivative calculation in the model is faulty. Just leave the partial derivatives disconnected and things work just fine.

0 Kudos
Message 2 of 9
(3,174 Views)

Thank you!  I'll check the math there.

 

Sorry about the maximized windows.  That's the way I like to work.  Must be a character defect.Smiley Wink

0 Kudos
Message 3 of 9
(3,170 Views)

Yes, my screen is 2560x1440, and with every VI I open I get a white-out condition, losing sight of everything else I am working on. 😉

 

I did not check you partial derivatives, but I think you also need to transpose the 2D array before wiring to the terminal.

0 Kudos
Message 4 of 9
(3,160 Views)

Aha!  The derivatives were correctly calculated, but it turns out that you need to transpose the derivatives array after you build it!  Not an obvious step, at least to me.

 

But now that this ate my entire afternoon, I'm likely to remember...

 

Thanks again for the help!!

0 Kudos
Message 5 of 9
(3,155 Views)

OK.  We were discovering that transpose thingy at the same time...

 

I have two (much, much) smaller monitors, so I max the front panel on one and the block diagram on the other.

 

But now I know what to whine to my manager about!

0 Kudos
Message 6 of 9
(3,151 Views)

I don't think the derivatives are correct, because the fitting seems very sensitive and does not always converge right.

 

I have not investigated further. There is almost never a need to provide analytical partial derivatives, especially since the additional complexity and additional sources of errors are negatives.

 

The reason for the need of a transpose of the partial derivatives array is mostly historical. In the old days, the function was often calculated point-by-point, autoindexing over X in a FOR loop (note that the model template still contains a FOR loop for no good reason! ;)). If you build the partial derivatives into a 1D array inside the FOR loop and autoindex at the FOR loop boundary, the resulting partial derivatives array is transposed relative to your method of operating loop-free on arrays.

 

0 Kudos
Message 7 of 9
(3,148 Views)

Old habits die hard.  I first started doing nonlinear fits on an IBM 360 (yes, punch cards) when all the routines I had access to required (correct) derivatives.  I know that the modern routines do just fine with numerical derivatives, but, as I said, old habits die hard.

0 Kudos
Message 8 of 9
(3,140 Views)

Yes, I learned FORTRAN IV with paper and pencil and punchcards. Our CDC-3200 was about the same vintage as the IBM/360. 😉

 

I any case, I created a document explaining how the partial derivatives need to be formatted. Maybe it is helpful for somebody. 😄

0 Kudos
Message 9 of 9
(3,095 Views)