Open mattborghi opened 3 years ago
The derivative w.r.t. tspan parameters isn't implemented even on ODEs. We just haven't thought about doing that. If you have a use case, we can keep this in mind and add it down the line though! It should just be a call to the rhs at the first and last time point right?
Results using FD present huge variability
For an SDE, you're doing the strong derivative so the derivative itself is stochastic and will change every call. Forward mode AD will work just fine for this calculation though. Finite difference would require that you provide a fixed noise process.
Comparison against SavingCallback results differ up to a minus sign, which is expected.
That works because the derivative of the mean is determinsitic even though the derivative itself is not.
Discretize-then-optimize: works only for ForwardDiffSensitivity() and the value returned is always the same.
Yeah that's just not implemented.
The „derivative“ of X(t) with respect to t is f(X(t)) + gdW/dt by definition so you should be able to work out a closed form
Yeah, so it's not difficult but just needs to be implemented.
The derivative w.r.t. tspan parameters isn't implemented even on ODEs. We just haven't thought about doing that. If you have a use case, we can keep this in mind and add it down the line though! It should just be a call to the rhs at the first and last time point right?
The idea of derivating the tspan
parameters comes from finance where we have to get
where u
is the solution of the SDE. It also has several uses in many applications but this is the straightforward way.
If you want I can reference you to some bibliography where this is implemented and it can be benchmarked.
Btw, what do you mean with your last sentence?
Yes, that's exactly what I meant. For ODEs, it's just f(u(0)) and f(u(tend)) that gives that derivative term. For SDEs, I haven't worked out how exactly to take into account the diffusion term. But we should at least add this to the ODE part of the interface ASAP since that's easy. For ODEs this can be done by using the derivative of the interpolation which would make it free.
I am trying to differentiate a SDE function w.r.t. a
tspan
parametert₀
usingZygote.jl Reverse Mode
but results in wrong values.A MWE is presented below comparing against
Zygote.jl Forward Mode
,Finite Differences
and usingSavingCallback
method.Evaluating the function works fine
Calculate derivatives using Duals/Zygote Forward Mode/FD
Comparison against
SavingCallback
results differ up to a minus sign, which is expected.Finally, using
Zygote.jl
Reverse Mode:ForwardDiffSensitivity()
and the value returned is always the same.Thanks in advance.