04-10-2014 02:53 PM
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.
Solved! Go to Solution.
04-10-2014 03:32 PM
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.
04-10-2014 03:38 PM
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.
04-10-2014 03:54 PM
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.
04-10-2014 04:18 PM
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!!
04-10-2014 04:21 PM
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!
04-10-2014 04:25 PM - edited 04-10-2014 04:31 PM
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.
04-10-2014 04:54 PM
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.
04-11-2014 03:42 PM - edited 04-11-2014 03:45 PM
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. 😄