patrick-kidger / patrick-kidger/diffrax
Question: Solving an SDE by applying an ODE Runge-Kutta method to the Stratonovitch form in Diffrax
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.1k
- Forks
- 189
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 1
Description
I used the method below to solve SDEs during my PhD, but I cannot tell if there is an equivalent method in diffrax. I learned about SDEs in an oblique way during my studies, so I'm lacking some technical background to recognize whether this is already implemented.
The method is as follows. For simplicity, consider the scalar SDE:
$$
dy = a(t, y) dt + b(t, y) dW.
$$
Under some moderate smoothness conditions on the $y$-dependence of $b(t,y)$, this can be converted to a Stratonovitch SDE of the form:
$$
\dot{y} = \left[a(t,y) - \frac{1}{2} b(t, y) \frac{\partial b(t, y)}{\partial y} \right] + b(t, y) \frac{dW}{dt} = f\left(t, y, \frac{dW}{dt}\right)
$$
Let us treat $dW/dt$ as a constant function over the interval $dt$. We can then solve this equation using a standard RK4 method as follows:
$$
\begin{align}
&k_1 = f\left(t, y, \frac{dW}{dt}\right), \
&k_2=f\left(t + \frac{dt}{2}, y + k_1 * \frac{dt}{2}, \frac{dW}{dt}\right), \
&k_3=f\left(t + \frac{dt}{2}, y + k_2 * \frac{dt}{2}, \frac{dW}{dt}\right), \
&k_3=f\left(t + dt, y + k_3 * dt, \frac{dW}{dt} \right),
\end{align}
$$
and then
$$
\begin{align}
&t' = t + dt, \
&y' = y + \frac{1}{6} (k_1 + 2 k_2 + 2 k_3 + k_4).
\end{align}
$$
The only reference I'm aware of for this method is from Wilkie and is intended to produced a solution to order $dt^2$ (which I understand elicited some negative reactions by people more knowledgeable than me). But in all cases that I used it for it gave the correct increment to order $dt^2$. I therefore found this to be really useful in practice.
So my questions are: is there an implementation of this kind of method in diffrax? And if not, is it something that would be advisable to implement in diffrax? And if not that, what would be the solver that behaves the closest to its intent?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing Diffrax's existing SDE solver documentation and implementations, then compare them with the Stratonovich RK4 procedure described in the issue. Determine whether an equivalent solver already exists, which existing solver best matches the intended method, and whether a new implementation is technically advisable; the issue does not name a file or test, and completion criteria remain open-ended.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100