Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

CurveFit.PolynomialFit Gives Bad Results for Fit Order > 3

I am experiencing spurious fit results when attempting to fit ~300 points to a fourth-order polynomial.
My x data values are in the range of 1.5 - 5 million and my y data values are in the immediate range of 4 million.
Is this a known problem?
0 Kudos
Message 1 of 6
(4,258 Views)
Palley,

This is not a known issue. There is an example program that should be found at the path below that I tried and worked properly for the case you described. Could you try this and see if you agree with its results?

\Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Examples\Analysis\CurveFitting\vb

Also could you send me a screen shot and possibly code that generates the data set that you are seeing this error with?

Thank you and have a great day!

Allan S.
National Instruments
0 Kudos
Message 2 of 6
(4,245 Views)
Due to schedule problems I am unable to perform your requested tests.
However, I already have an Excel file I had generated demonstrating the problem I have encountered. It is attached.

The call I make to get the results of Sheet2 is:

..
double[] fitVals = NI.CurveFit.PolynomialFit(tempsFixed, sensors, fitOrder, out coeffs, out err);
..

the "temps" column corresponds to the input array "tempsFixed", "sensor" corresponds to the input array "sensors", and fitOrder has the value 4. The column labelled "fit" displays the return values returned in the "fitVals" array. I extracted these data values by cutting and pasting from the Visual Studio Watch window during a breakpoint in program executions just following the statement above.

I tried scaling both the x and y data to each fit in the range -1.0 to +1.0 by subtracting the midrange value of each data set and then scaling each to the min-to-max range. Then the fit is correct as evidenced in the plot of Sheet1. I have derived transformations of the fit coefficients back to the original scaling and tested the results and am using this workaround strategy for now.
0 Kudos
Message 3 of 6
(4,235 Views)
Palley,

Is this workaround you found acceptable for you? You spreadsheet illustrates this error very clearly thank you for that. I am going to report this to R&D for further investigation. I will report my findings as soon as possible. Have a great day!

Allan S.
National Instruments
0 Kudos
Message 4 of 6
(4,221 Views)
Yes, the workaround seems to meet my needs.
I would like to be informed when the issue is resolved.
Note: I don't seem to be notified by email anymore when an answer is posted, even though I've requested it. Since I get the weekly update of issues OK, I assume the such emails are not succumbing to our spam filter. Any thoughts?
Thanks
0 Kudos
Message 5 of 6
(4,208 Views)
Hello,

Allan is out of town this week, but it seems that he has already escalated this issue to the Research and Development group for Measurement Studio. I imagine that he has listed you as a contact so that you will be notified when the problem is resolved. Similarly, he may have put his own information down and plans to contact you himself at such a time. With regards to the emails, I agree that you are probably filtering them out. Thank you for contacting National Instruments and take care!

Sincerely,

Aaron B.
National Instruments
0 Kudos
Message 6 of 6
(4,184 Views)