|
From: | andrea console |
Subject: | Re: help for least squares |
Date: | Wed, 26 Jun 2013 22:01:27 +0200 |
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<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.
_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave
[Prev in Thread] | Current Thread | [Next in Thread] |