LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in "Linear fit.vi"

 

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.

 

Test Linear FIT.png

 

 

"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"

 

Test Linear FIT+.png

 

Download All
0 Kudos
Message 1 of 3
(2,323 Views)

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 ...). 😄

0 Kudos
Message 2 of 3
(2,304 Views)

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.

 

Smiley Embarassed

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"

 

 

 

 

0 Kudos
Message 3 of 3
(2,285 Views)