LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

weighted linear fit

Hi guys, maybe I'm missing something, but I could not find a vi for a weighted linear fit (LV 7.1). Do you know if it exists?
In fact, I'm trying to do a loess smoothing, which I could not find, too.
Thank you in advance

Paolo
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 1 of 8
(4,211 Views)
It sounds to me like this would be a good time to use mathlink.  I haven't toyed with it yet, but it is supposed to be like MatLab  and I use Matlab all the time to do weighted regressions.  If W is a diagonal matrix of inverse weights, then

(W'X'WX)^-1*W'X'WY

would give you a 2X1 matrix of slope and intercept.
0 Kudos
Message 2 of 8
(4,207 Views)
I meant to say "MathScript," not "MathLink."
0 Kudos
Message 3 of 8
(4,205 Views)
something like this may work, but the code I put into the mathscript doesn't seem to do the job. 
0 Kudos
Message 4 of 8
(4,203 Views)
Thank you CFAMS Brad for your suggestions, but MathScript is a new 8.0 feature and I'm still stuck with 7.1.
Surprisingly, trying to open your vi with 7.1 does not give any results (no message nor crash).
I will consider promoting to 8, or write the code myself. (BTW the Linear Fit vi in LV8 do have a Weight input).

Paolo
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 5 of 8
(4,190 Views)
Hello pincpanter and CFAMSBrad,

what about using simple math functions to do the calculation of your formula? In function palette Analyze->Mathematics->LinearAlgebra you will find all functions needed to do this!
(Dot Product, A×B, InverseMatrix)




Message Edited by GerdW on 04-27-2006 09:33 AM

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 8
(4,187 Views)
Thank you GerdW, I will try this way.

Paolo
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 7 of 8
(4,176 Views)

Despite these previous messages, I'm not able to perform a weighted linear least squares fit. I'd like to do it directly in Labview with a 1/x weight distribution.

May someone help me to carry out that fit?

0 Kudos
Message 8 of 8
(4,134 Views)