|
From: | Pavel Hofman |
Subject: | Re: Custom jacobian (dfdp) in nonlin_curvefit - calling parameters? |
Date: | Sat, 16 Nov 2019 09:30:36 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 |
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)?
One more related question. In my other code I nonlin_curvefit 4 parameters to two equations (each using all of the params), again for a row/vector of independent times t (i.e. x). As a result, my f(p, x) returns a 2D matrix. Works perfect. When providing a custom dfdp function, what dimensions should its output have? 2D + 1D for each p, i.e. 3D?
Thanks a lot, Pavel.
[Prev in Thread] | Current Thread | [Next in Thread] |