Turing.jl icon indicating copy to clipboard operation
Turing.jl copied to clipboard

Linear SDEs

Open kaandocal opened this issue 2 years ago • 2 comments

Hi and apologies if this has already been answered before (I haven't found any references in the documentation or the issues regarding this issue), but is there a good way to do exact inference on linear SDEs with Turing? The documentation contains an SDE example where the likelihood is estimated from sample trajectories, but the output distribution of linear SDEs can be computed exactly from the drift/diffusion matrix so this should not be necessary.

kaandocal avatar Apr 08 '22 15:04 kaandocal

If you know the solution (such as e.g. for linear SDEs) and want to exploit it, probably the easiest thing to do (right now) is to use the explicit solutions in your model directly and not solve any SDE at all. I.e., you would not add any solve calls etc.

A possibly more convenient option would be to be able to write something like

observations ~ DifferentialEquation(prob, solver, ....; kwargs...)

(maybe DESolution would be a bit shorter...), which could then dispatch depending on the type of prob and exploit explicit solutions automatically and fall back to solve calls otherwise. The main question here is where such glue code should live - currently, you can just use StochasticDiffEq with Turing without Turing knowing about its existence which is easy and gives you a lot of flexibility.

devmotion avatar Apr 08 '22 20:04 devmotion

That's a good question! Theres ControlSystems.jl but that's a huge package. I was thinking of something along the lines of

sdeprob = LinearSDEProblem(drift, diffusion, u0, (0, tmax), p)
observations ~ sdeprob(10:10:100)

would be nice to have. As I am not aware of how exactly to implement something like this in Turing syntax maybe the following will suffice for now:

observations ~ MvNormal(sdeprob, 10:10:100)          # automatically compute means and (auto)covariances

But then there is no specialised LinearSDEProblem type and I'm not sure if there's any demand, maybe over at ModelingToolkit.

kaandocal avatar Apr 10 '22 16:04 kaandocal