Re: lsqnonlin - any difference for myfunc() to return vector or norm(vector)^2 ?



On Jan 18, 7:22 pm, John D'Errico <woodch...@xxxxxxxxxxxxxxxx> wrote:
In article <07901b77-0ea0-49cb-ad2b-1af5f3f09...@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,spasmous<spasm...@xxxxxxxxx> wrote:

I am doing a minimization using lsqnonlin. There are 5 unknowns and 10
measurements. The documentation says to return a vector of residuals
but I prefer to return the sum of squares error - is there any
material difference? It seems happy, even though there is nominally
only one residual value and 5 unknowns.

Yes, there is clearly a difference. Since lsqnonlin
will form the sum of squares of the VECTOR that it
expects to see, then minimize that, if you return
only a scalar quantity, it will produce a different
result. At the very least it will be far less
accurate, since you are squaring a square.

Were you working in infinite precision, the minimizer
of the sum of squares should be the same as the
minimizer of the square of the sum of squares. But
why do it?

John


Actually a real reason - for my problem I am seeing the error message:

?? Error using ==> unknown
Maximum variable size allowed by the program is exceeded.

Error in ==> optim\private\nlsq at 115
JACFD = zeros(nfun, numberOfVariables); ü·¢xPet to correct
size


The number of unknowns is 130 000 and the number of measurements is
500 000. It can't make a Jacobian that size so I am norming the
residual vector... sadly lsqnonlin doesn't seem to minimize the norm
of the residual very well like this.

Currently I'm trying fminsearch since it only wants norm(residual)^2
but I'm not hopeful about simplex on this problem.
.



Relevant Pages

  • Re: Least squares optimizing for equal positive & negative error sums
    ... I'm looking for something that will generate coefficients similar to typical least squares analysis, but instead optimizes for an equal amount of positive and negative error between the polynomial and the measured data. ... You could use an augmented objective function which is the sum of the squares of the fitting errors, PLUS some big whopper constant times the difference between the sum of positive errors and the sum of negative errors. ... Compute the residuals, and find the sum of the positive ...
    (comp.soft-sys.matlab)
  • Re: lsqnonlin question again
    ... the sum of the values of the residuals ... >,rather than the sum of squares add up to zero. ... > the lsqnonlin code, but this behavior is making me suspect that the ...
    (comp.soft-sys.matlab)
  • Calculating Standard Deviation
    ... Here is the first of my statistics/least squares questions... ... When calculating the standard deviation for a set of values you use the ... sum of all the residuals squared. ... Is this done to remove the tendency for residuals that result from ...
    (sci.math.num-analysis)
  • Re: fminsearchbnd not finding right values (when between upper & lower limit)
    ... FitEr = trapz); ... Just sum the absolute ... residuals, or sum the squares of the residuals. ...
    (comp.soft-sys.matlab)
  • Re: lsqnonlin - any difference for myfunc() to return vector or norm(vector)^2 ?
    ... The documentation says to return a vector of residuals ... but I prefer to return the sum of squares error - is there any ...
    (comp.soft-sys.matlab)