04-07-2009
04:26 PM
- last edited on
06-04-2024
12:37 PM
by
Content Cleaner
Hi. I'm using the curve fitting vi in Labview 8.0. I'm doing an unweighted fit, and I get negative values for the "residue". I get negative values for all three curve fitting methods: least squares, least absolute residual, and turkey bisquare. The "residue" is supposed to be weighted mean square error for the least square and bisquare methods. I can't figure out how this could possibly be negative if it's squared. I looked at the equations in the help file and here (https://www.ni.com/en/shop/labview/overview-of-curve-fitting-models-and-methods-in-labview.html) and it looks like all the numbers are squares and should be positive.
Can anyone give me an idea of what I'm missing?
Thanks
04-08-2009 11:58 AM
04-08-2009 03:42 PM
Hi. Thank you for the offer to help. What would you like for me to post on here exactly? The vi I have written takes data from instrumentation, performs the curve fit, and then writes the output to an output file. It wouldn't be able to run if it didn't have the associated instrumentation.
I'm self taught on LabView, so I only have learned how to do what's needed to make my programs and instruments do what I want. I haven't learned anything about sharing the VIs or results.
Thank you,
Brian
04-08-2009 04:24 PM - edited 04-08-2009 04:26 PM
Click on Add Attachments when you reply to this messsage and attach a copy of your vi. I would copy the vi after runing it once and change any input parameters to a constant that way we should be able to reproduce the behavior the way you see it.
There are many self taught labview uses on the forums. Regards, -SS
04-09-2009 10:33 AM
Hello,
If you could post your VI or even screen shots of the code, that would be great to see how this is happening.
Thanks,
Anna K.
04-09-2009 11:26 AM
04-09-2009 11:39 AM - edited 04-09-2009 11:43 AM
Mathematically, the residue can only be negative is the weight is negative.
The residue is the sum of the squared differences between y(data) and y(fit) (=always positive! or absolute difference, also positive, depending on the method.) multiplied by the weight and divided by N (always positive!).
Could it be you have some inputs wired wrong? The nonlinear fit VIs have the code exposed, and they explicitly take the absolute values of the weight for protection. I don't know if the linear fit does the same.
04-09-2009 11:52 AM
04-09-2009 01:20 PM - edited 04-09-2009 01:21 PM
Don't confuse "residual" and "residue". The residual is the difference between signal and fit, and is actually an array of three elements in your case. Look at the dynamic data instead of coercing it to a scalar DBL.
from the help:
residual | Returns the difference between the original data and the best fit. |
04-09-2009 03:46 PM
Hi all. Thank you for the replies. I tried today to do as recommended and change the variables to constants for posting here. The trouble is that the program take a long time to run and acquire the data, or else it's random rather than linear. After messing up a few times, I had run out of time. Hopefully I can post something here on Monday night.
Thanks,
Brian