help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: help for least squares


From: vathomas
Subject: Re: help for least squares
Date: Sat, 22 Jun 2013 09:43:51 -0700 (PDT)

Hi

To solve an unconstrained least square problem octave provides the "\"
operator.
Make a matrix A holding the a_? values along with the ones, and a vector
containing the b_? values. Then you can use the operator. For example (let
say you have 16 values):

as = [a_0; a_1; ...; a_15];
bs = [b_0; b_1; ...; b_15];
A = [as, ones(16, 1)];
x = A\b;

where x will hold the results. (Note that "..." should be filled with your
values.)

Some remarks:
1) The above does not enforce that 0<x&lt;1. To do that explicity you need a
constrained least squares routine. But you may be lucky ... If not, ask in
the list for such a routine as I do not know one.
2) Check that your problem is numerically well posed. Using the function
cond(A), you can see the condition number of your matrix A. The smaller the
better. If is two high (> 1e5) you probably have to scale your a's and b's
values.

best
Thomas
 



--
View this message in context: 
http://octave.1599824.n4.nabble.com/help-for-least-squares-tp4654666p4654670.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]