10-18-2013 05:14 AM - edited 10-18-2013 05:15 AM
Calculating the slope by using a Linear fit through several points should be independant of the used X-values.
When passing data coming in from a waveform with actual time as X-values (large DBL timestamps),
the results are different when compared to using a relative time.
I first discovered this bug in 8.5.1 got the same results in LV2012 SP1
In the attached example (8.5.1) I've regenerated the problem with "Linear Fit.vi"
both the Methods "Least Square" and "Least Absolute Residual" return the same slope
but the returened "Best Linear Fit" for the second method match better with the provided points.
"Linear Fit Coefficients.vi" has similar issues,
the calculated slope is identical for "Least Square" but gives again different results for "Least Absolute Residual".
I've attached an additional example (8.5.1) displaying the differences in calculations between "Linear Fit Coefficients.vi" and "Linear Fit.vi"
10-18-2013 07:21 AM - edited 10-18-2013 07:23 AM
Probably not a bug. I bet you are running into a bit starvation and conditioning problem because the absolute X varies by less than 1e-9 when using absolute time.
Try to write your own algorithm and see if you can do better (Maybe with some smart reordering of operations ...). 😄
10-18-2013 08:56 AM - edited 10-18-2013 09:01 AM
In my code I have already solved this problem by subtracting the initial time from the time-data.
Since this was the second time I got bitten this way, I though to file it as a bug report...
I had already guessed it could have something to do with the small changes / large number of significant digits in the timestamp.
Decreasing the tolerance did not change the results either.
My second remark on the differences in calculations between "Linear Fit Coefficients.vi" and "Linear Fit.vi" can be skipped. (I wasn't able to edit my initial post anymore)
The "Method" input of the "Linear Fit Coefficients.vi" was not connected so I was comparing "Least Square" with "Least Absolute Residual"