[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: least square
From: |
heberf |
Subject: |
Re: least square |
Date: |
Thu, 5 Aug 1999 16:14:21 -0500 (CDT) |
I tried this myself and I think the Octave solution is the correct one. But
maybe I misunderstand what you mean by a least square soluntion to the
overdetermined problem. What I THINK you mean is find x to minimize the norm of
Ax - b
(which is of course the same as minimizing the sum of squared elements of the
above vector). This problem has a closed form solution which is given by
x = inv(A'*A)*A'*b
You can check that for your problem this return the same thing as x = A\b. Now
notice that the norm of Ax -b is 2.3748 while for the solution you suggest the
norm is bigger. Also note that since one column of A is a vector of ones the
sum of Ax - b should be zero. It is for the Octave solution. For your
solution
it's considerably larger (I assumed that you miswrote -0.365 and 0.783 as -365
and 783 in your e-mail).
Does this help? If not what do you mean by a least squares solution?
Heber Farnsworth
>
> I ran the following standard example taken from IMSL(and also
> checked with Matlab ) for least square solution of Ax = b,
> where
>
> octave:4> A = [1,5,15,5;1, 4,17,4 ;1,7,14,7;1,3,18,3;1,1,15,1;\
> 1,8,11,8;1,3,9,3;1,4,10,0]
> A =
>
> 1 5 15 5
> 1 4 17 4
> 1 7 14 7
> 1 3 18 3
> 1 1 15 1
> 1 8 11 8
> 1 3 9 3
> 1 4 10 0
>
> octave:5> b = [30;31;35;29;18;35;20;22]
> b =
>
> 30
> 31
> 35
> 29
> 18
> 35
> 20
> 22
>
> octave:6> x = A\b
> x =
>
> 1.48165
> 2.59948
> 1.01204
> 0.22104
>
> The actual LEAST SQUARE solution for the overdetermines system
> ( which is ,as I assume, not same as the minimum norm soln for
> singular matrices ) is:
>
> X = .636, 2.845, 1.058, 000.
> with residuals r = -.733, .996, -365, 783, -1.353, -.036, 1.306, -.597
>
> Does octave support a linear least square solving code or am I doing
> something wrong? ( Mr. David Doolin suggested that I resubmit this ).
>
> Thanking you,
>
> sincerely,
>
> A. K. Mitra, address@hidden
>
>
>
>
> ---------------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL. To ensure
> that development continues, see www.che.wisc.edu/octave/giftform.html
> Instructions for unsubscribing: www.che.wisc.edu/octave/archive.html
> ---------------------------------------------------------------------
>
---------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL. To ensure
that development continues, see www.che.wisc.edu/octave/giftform.html
Instructions for unsubscribing: www.che.wisc.edu/octave/archive.html
---------------------------------------------------------------------