Graphics Programs Reference
In-Depth Information
sigma = 0;
fori=1:n
y = polyEval(coeff,xData(i));
sigma = sigma + (yData(i) - y)ˆ2;
end
sigma =sqrt(sigma/(n - m));
functiony=polyEval(coeff,x)
% Returns the value of the polynomial at x.
m = length(coeff);
y = coeff(1);
forj=1:m-1
y = y*x + coeff(j+1);
end
Weighting of Data
There are occasionswhenconfidence inthe accuracy of datavaries frompointtopoint.
For example, the instrumenttaking the measurements may be moresensitive in a
certain rangeofdata. Sometimes the datarepresent the results of severalexperiments,
each carried out underdifferentcircumstances. Under these conditions we may want
to assign a confidence factor,or
weight
,toeach datapoint and minimize the sum of
the squares of the
weighted residuals r
i
=
W
i
[
y
i
−
f
(
x
i
)], where
W
i
are the weights.
Hence the function to be minimizedis
n
W
2
i
f
(
x
i
)]
2
S
(
a
1
,
a
2
,...,
a
m
)
=
[
y
i
−
(3.24)
i
=
1
This procedureforces the fitting function
f
(
x
) closer to the datapoints thathave
higherweights.
Weighted linear regression
If the fitting functionis the straight line
f
(
x
)
=
+
a
bx
, Eq. (3.24) becomes
n
W
i
(
y
i
−
bx
i
)
2
S
(
a
,
b
)
=
a
−
(3.25)
=
i
1
The conditionsfor minimizing
S
are
n
∂
S
W
2
i
a
=−
2
(
y
i
−
a
−
bx
i
)
=
0
∂
i
=
1
Search WWH ::
Custom Search