5.0 KB · commit a9602da
In the previous section, we have minimized the sum of squares of the errors. A more general approach is to minimize the weighted sum of the squares of the errors taken over all data points. If this sum is denoted by S, then instead of Eq. (4.2), we have
S=W1[y1−f(x1)]2+W2[y2−f(x2)]2+⋯+Wm[ym−f(xm)]2=W1e12+W2e22+⋯+Wmem2.(4.26)In Eq. (4.26), the Wi are prescribed positive numbers and are called weights. A weight is prescribed according to the relative accuracy of a data point. If all the data points are accurate, we set Wi=1 for all i. We consider again the linear and nonlinear cases below.
Let Y=a0+a1x be the straight line to be fitted to the given data points, viz. (x1,y1),…,(xm,ym). Then S(a0,a1)=i=1∑mWi[yi−(a0+a1xi)]2.(4.27) For maxima or minima, we have ∂a0∂S=∂a1∂S=0,(4.28) which give ∂a0∂S=−2i=1∑mWi[yi−(a0+a1xi)]=0(4.29) and ∂a1∂S=−2i=1∑mWi[yi−(a0+a1xi)]xi=0.(4.30) Simplification yields the system of equations for a0 and a1: a0i=1∑mWi+a1i=1∑mWixi=i=1∑mWiyi(4.31) and a0i=1∑mWixi+a1i=1∑mWixi2=i=1∑mWixiyi,(4.32)
which are the normal equations in this case and are solved to obtain a0 and a1. We consider Example 4.2 again to illustrate the use of weights.
Solving the preceding equations, we obtain a0=−1.41258anda1=2.69056. The required 'linear least squares approximation' is therefore given by y=−1.41258+2.69056x, and the value of y(5)=12.0402. It follows that the approximation becomes better when the weight is increased. ◀
We now consider the least squares approximation of a set of m data points (xi,yi),i=1,2,…,m, by a polynomial of degree n<m. Let y=a0+a1x+a2x2+⋯+anxn(4.33) be fitted to the given data points. We then have S(a0,a1,…,an)=i=1∑mWi[yi−(a0+a1xi+⋯+anxin)]2.(4.34) If a minimum occurs at (a0,a1,…,an), then we have ∂a0∂S=∂a1∂S=∂a2∂S=⋯=∂an∂S=0.(4.35) These conditions yield the normal equations
a0i=1∑mWi+a1i=1∑mWixi+⋯+ani=1∑mWixina0i=1∑mWixi+a1i=1∑mWixi2+⋯+ani=1∑mWixin+1a0i=1∑mWixin+a1i=1∑mWixin+1+⋯+ani=1∑mWixi2n=i=1∑mWiyi=i=1∑mWixiyi ⋮=i=1∑mWixinyi.⎭⎬⎫(4.36)Equations (4.36) are (n+1) equations in (n+1) unknowns a0,a1,…,an. If the xi are distinct with n<m, then the equations possess a 'unique' solution.