06-08-2010 09:06 AM
Hi all -
When using the Nonlinear Curve Fit VI, I was getting the same error that a lot of people in the forum seem to be getting, namely that the optimization won't work because there is at least one Inf / NaN / etc.
I tried finding out where that was coming from and found that the LM abx sub-VI gives me zeroes for alpha, beta, and chisqr matrix (see probes 315-317), but once the values come out of that subVI they report as NaN (see probes 303-306)... somehow they seem to switch values which ruins everything past that point. (I apologize if the picture is confusing but I was trying to show several things at once.)
So I have two questions - 1) Does anyone have any idea why this is happening or have any suggestions?
2) What do alpha and beta correspond to in LM calculations? (I have looked at how LM works but I'm not sure what they represent. Inside the abx sub-vi are some other VIs but you can't probe / highlight, so it's hard to gauge what they're doing.)
Thanks for any help.
06-08-2010 10:16 AM
06-08-2010 10:24 AM
Dan K wrote:When using the Nonlinear Curve Fit VI, I was getting the same error that a lot of people in the forum seem to be getting, namely that the optimization won't work because there is at least one Inf / NaN / etc.
06-08-2010 11:15 AM
Thanks for your questions and help so far. I know what you mean about the clone issue and I'm 99% sure that's not the problem.
If you'd like to play around with it, I attached a typical way to fill in the values on the FP (second image). (If you are in this window and scroll down just a bit that's where I hide the outputs from the LM VI). It's based on something called prism coupling, where you use a prism with a known refractive index and known prism angle to determine the refractive index of the unknown material. (You rotate the prism thru an angle until the internal reflected light intensity increases to 100%, and then you've reached the critical angle which gives you the refractive index of the material.)
Initially, when I only had access to the most basic LabView package, what I did was put in a range of prism indices and unknown material indices and then plot those (tab 1) and they are listed left-to-right below the plot. Then I wrote a chisquared calculation and on tab 2 you can find the 10 best (lowest chi squared) plots, so you can sort of see which prism and unknown material values match your plot the best. This worked fine.
THEN I got access to professional development version, and tried implementing L-M per my boss' recommendation. The problem with software for this is that the function curves up to y=1 and then above that it blows up to infinity (because of sine terms etc). So what I tried to do was cut off values above 1 (hence the array being called "thetabelow1").
SOOOO there is a good chance it's my data and I understand that, but I don't understand why abx is shooting out NaN when I am watching the values inside abx report as zeroes. (If you change the 1.69 and 1.49 values in the first image to something like 1.701 and 1.51 it does a better job, because it approaches from the other direction).
(Note, when I attached the VI the L-M didn't work because the computer I attached it from doesn't have the professional version (that's a laptop which will run the experiment and isn't online). Simply replace the broken L-M VI when you download it and the broken arrow should go away.)
Let me know if you have any thoughts on how to work with the data to get it into a format which the L-M can use, or if you know how I can find out what the sub-VIs do (still trying to figure out alpha and beta). Thanks a lot!
06-08-2010 12:00 PM
Sorry, but I'm not going to wade through a VI with sequences stacked 22 deep swarming with local variables.
Can you reduce it to "outer frame 10", "inner frame 2" and replace the inputs with diagram constants or controls containing typical data. Thanks!
06-08-2010 12:29 PM
Hah... I completely understand and would never ask that of anyone! You only had to look at that frame. But I extracted that frame and put it into this VI. The problem is that the function is discontinuous at the critical angle, and so I don't think L-M can approach from above the angle, only from below. I'm thinking of modifying inside of the L-M VI to somehow discern this. But I need to know that abx is passing the right values, and I'm trying to figure out what alpha and beta are.
06-08-2010 12:42 PM
06-08-2010 12:46 PM
Your controls (input indicators acting as controls via local variables in your case) are empty.
Turn them into controls (right-click...change to control) and get rid of the locals.
Make sure to make current values default before saving.
06-08-2010 12:55 PM
here you go. very typical values. remember that the function is discontinuous past the last data point which is why the data set is chopped off there. but it is continuous up to that point, and should be able to be matched by the function. the right answers in this case are 1.5 and 1.7.
thanks again!
06-08-2010 12:56 PM