# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Weight values in weighted linear fit

I am using Labview 8.5, which has the weighted linear fit vi.

What values are acceptable as weights? In other fitting software the weights expected are usually standard deviations of each value. It seems to me that the weights expected by the weighted linear fit vi are in a range from 0 to 1, corresponding to how much you value that point.

What is the vi actually looking for? Some value between 0 and 1 or the standard deviation for each particular value of the dependent variable?

I can't tell just by reading the help or looking online.

Message 1 of 6
(3,080 Views)
Solution
Accepted by topic author VariableRange

## Re: Weight values in weighted linear fit

You can use any weight you want, from zero to near infinity.

If you know the variance for your data, set the weight as the inverse of the variance (See also).

weight = 1/variance or

weight = 1/(standard deviation)²

Message 2 of 6
(3,077 Views)

## Re: Weight values in weighted linear fit

Thanks for the quick reply, altenbach!

Ok, so it is the inverse of the variance. Other software will ask for standard deviation as the weight. Others will ask for 1/standard deviation. Labview is the only one that I've seen that is asking for 1/variance.

Since the help file doesn't address this, can I assume that this is very standard practice and anyone familiar with the term "weight" when it comes to fitting a function will automatically assume it means 1/variance?

Message 3 of 6
(3,073 Views)

## Re: Weight values in weighted linear fit

Prior to LabVIEW 8.0, there was a "standard deviation" input instead of a weight input for the nonlinear fit function, but internally the code was basically the same (It was immediately converted to a weight internally).

Weight is better and more convenient because you can completely disregard portions of the data by setting the weight to zero, while it would be weird trying to set the standard deviation to infinity to get the same effect (well, it would not work unless the function can detect that special case and adapt to it). 😉

Since it is mathematically very simple to translate an standard deviation into a weight, you can do that easily yourself.

Message 4 of 6
(3,065 Views)

## Re: Weight values in weighted linear fit

Cool. Thank you.

At least now I know what the vi is looking for.

Message 5 of 6
(3,060 Views)

## Re: Weight values in weighted linear fit

Quote from wikipedia on Linear Least Squares (mathematics):

"The weights should, ideally, be equal to the reciprocal of the variance of the measurement"

Message 6 of 6
(3,055 Views)