help-octave
[Top][All Lists]
Advanced

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

Re: leasqr help


From: Olaf Till
Subject: Re: leasqr help
Date: Thu, 10 Apr 2008 12:38:49 +0200
User-agent: Mutt/1.5.13 (2006-08-11)

On Wed, Apr 09, 2008 at 05:54:06PM +0200, Francesco Potorti` wrote:
> >> >In case a have a "Matrix" as data, would it work right ?
> >> >In this case my "function" should return a matrix as well ?
> >> 
> >> Supposing that by "data" you mean the "observed values", the answer is
> >> no: the function should return a scalar value.
> >
> >Sorry, but this is not true ... if you do not mean a different
> >'leasqr.m'; I have the one with the help text below in mind.
> >
> >leasqr accepts vectors of observed values, and the user-supplied
> >function should compute a vector with as many elements as observed
> >values.
> 
> Yes, this is true.  But the vectors are intended as "one observation per
> row", like this:
> 
> % x = column vector or matrix of independent variables, 1 row per
> %   observation: x = [x0 x1....xm].
> % y = column vector of observed values, same number of rows as x.
> 
> This is conceptually the same as calling f once per row, that is,
> f(x,p)(i) only depends on x(i,:) and p.  True, you can write an f
> function that behaves differently, but this is not how leasqr is
> intended to be used.

This is a snippet from leasqr.m ("F" is the user-supplied function,
"y" is the vector of observations):

% set up for iterations
%
f=feval(F,x,p); fbest=f; pbest=p;
r=wt.*(y-f);

You see that the observations "y" and the result of "F" (i.e. "f")
must be vectors of the same length.

> 
> The main issue is that the error that leasqr minimises is the sum of
> squared differences y-f(x,p), so the only distance measure available is
> point by point.  If you want to minimise something different, you could
> look inside leasqr.m ancd change the few lines where the sum of sqared
> differences is computed (look for the variable called ss).

This Levenberg/Marquardt optimization, which implies that it uses
gradient information of "point to point" distances to minimize the sum
of squared distances. Unless you have some complicated variant of this
algorithm in mind, you can not simply change it by computing something
different in "ss".

Olaf


reply via email to

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