LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bug In Linear Fit.vi?

I ran into a weird bug with Linear Fit.vi today. It's not a big deal (I don't expect users to stumble onto it during normal operation), but my boss found it when I was demoing the software, and I thought I'd check and see if I'm doing something wrong, or if it's actually a bug in the implementation.

I've attached a VI that reproduces the problem. If you feed the Linear Fit.vi multiple copies of the same point, eg (1,1), for some points the output is not reliably the same. For example, if you input two (1, 1.2) points, it returns NaN for both slope and offset. Sounds good. But if three copies of that point are entered, it returns a slope of 0 and an offset of 1.0. This process continues for various numbers of points, with it changing between NaN, and (0, 1.0) in no obvious pattern. The behavior appears to be different for different starting values.

Is this the expected execution? I would prefer a reliable NaN for any number of matching input points. Is my example doing something funny that gives me these results?

Thanks!
Drew
0 Kudos
Message 1 of 2
(2,522 Views)
I duplicated what you have been seeing. Apparently, the linear fit.vi is using the basic formula for calculating slope and intercept.


A linear fit can have duplicate and non duplicate points.
However, You are simulating an unusual set of data. It does not make sense to fit a curve to one or more duplicate points alone. In a case like this you should edit your vi and check the data for duplicate points alone, and then report an error or decide on how to handle the data.
0 Kudos
Message 2 of 2
(2,508 Views)