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: Pavel Hofman
Subject: Re: Custom jacobian (dfdp) in nonlin_curvefit - calling parameters?
Date: Sat, 16 Nov 2019 20:24:26 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0

Dne 16. 11. 19 v 9:30 Pavel Hofman napsal(a):
Hi Olaf,


The interface of your functions and the way you call nonlin_curvefit
seem ok. The code inside f_dfdp() doesn't seem ok. I don't think the
documentation of the optim package contains an example for explicitly
computing a Jacobian with m-code (because this is not specific to the
optim package). But in the code of 'optim_problems.m' there is an
example:

   ret.curve.schittkowski_327.dfdp = ...
       @ (x, p) [1 + exp(-p(2) * (x - 8)), ...
        (p(1) + .49) * (8 - x) .* exp(-p(2) * (x - 8))];

Note that 'x' (or 't', in your code) is a column vector.

Thanks a lot for your help.

Function APIs of that example are:

ret.curve.schittkowski_327.f = @(x, p) ......
ret.curve.schittkowski_327.dfdp = @(x, p) ......

while nonlin_curvefit has @(p, x). Should the partial derivative dfdp function for nonlin_curvefit be @(x, p), or @(p, x)?

Trial/error shows the @(p, x) dfdp API is the case for nonlin_curvefit. Works perfect now when I fixed my dfdp function to use element-by-element multiplication.

As of performance - The precisely calculated dfdp function never gives worse results than real finite differences. Time performance in my case depends on length of the independent vector - from 60% to 130% of the default real finite differences.

I just wonder how the 2D case should be handled.

Thanks a lot,

Pavel.



reply via email to

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