help-octave
[Top][All Lists]
Advanced

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

Re: Custom jacobian (dfdp) in nonlin_curvefit - calling parameters?


From: Olaf Till
Subject: Re: Custom jacobian (dfdp) in nonlin_curvefit - calling parameters?
Date: Tue, 19 Nov 2019 12:04:44 +0100
User-agent: NeoMutt/20170113 (1.7.2)

On Tue, Nov 19, 2019 at 12:00:25AM +0100, Pavel Hofman wrote:
> 
> Dne 18. 11. 19 v 18:39 Olaf Till napsal(a):
> > 
> > 'dfdp'
> >       Function computing the Jacobian of the residuals with respect to
> >       the parameters, assuming residuals are reshaped to a column vector.
> > 
> > So for calculating the Jacobian, assume that the array returned by 'f'
> > is reshaped to a column vector (as with array(:)). So the Jacobian is
> > 2D.
> > 
> > (The differences between nonlin_curvefit and nonlin_residmin do not
> > affect this.)
> > 
> 
> Now my f returns one vector column (first half output of the first function,
> the second half output of the second function).
> 
> The default dfdp of minimum differences works perfect. The sum of errors is
> 1e-17 in about 7 iterations.
> 
> sum((y - model_values).^2) with 2000 values.

This tells us nothing without knowing how large your elements of 'y'
are.

> My dfdp is IMO correct now, I checked several times. Yet I never get more
> than 3 iterations, with the sum of errors about 1e-10 which is too inprecise
> for my case.

My guess is that your custom dfdp still has some error (I didn't
check).

You could check your custom dfdp against finite differences, maybe
playing with 'FinDiffRelStep', 'FinDiffType', and 'TypicalX'. For more
accuracy you could use the function 'jacobs' for complex step
derivatives, if your 'f' allows it.

A study of 'optim_doc' should help you in figuring out the above.

> I configured:
> 
> settings = optimset ('dfdp', fDfdp, 'TolFun', 1e-17, 'TolX', 1e-17,
> 'Display', "iter");

'TolX' is not honoured by the default algorithm (which is mentioned by
'optim_doc'). 'TolFun' is the minimum _fractional_ improvement of the
sum of squared residuals, so setting it to less than machine epsilon,
as you did, means the algorithm will start a new outer loop after any
improvement (which is not necessarily good, since the inner loop won't
further try to refine the direction of the step).

> No change, always only 2 - 3 iteration. I am listing dfdp output before
> leaving the function and values in the four columns of dfdp output make
> sense.
> 
> Please could the real-finite differences DFDP do someting significantly
> different than a custom dfdp in terms of settings and tolerances? I did not
> see anything in __nonlin_residmin__ nor in __lm_svd__ when stepping through
> the code in debugger.

No, the only thing different should be which Jacobian function is
called.

Olaf

-- 
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net

Attachment: signature.asc
Description: PGP signature


reply via email to

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