sde_euler_step#
- class braintools.quad.sde_euler_step(df, dg, y, t, *args, sde_type='ito', **kwargs)#
One Euler–Maruyama step for Ito SDEs.
This integrates an Ito SDE of the form
\[dy = f(y, t)\,dt + g(y, t)\,dW,\]where
fis the drift andgis the diffusion, usingy_{n+1} = y_n + f(y_n, t_n) dt + g(y_n, t_n) dW_nwithdW_n ~ Normal(0, dt)applied per PyTree leaf.- Parameters:
df (
Callable[[PyTree,float|Quantity,...],PyTree]) – Drift functionf(y, t, *args)returning a PyTree matchingy.dg (
Callable[[PyTree,float|Quantity,...],PyTree]) – Diffusion functiong(y, t, *args)returning a PyTree matchingy.y (
PyTree) – Current state.t (
float|Quantity) – Current time (scalar or array broadcastable withyleaves).*args – Extra arguments passed to
dfanddg.sde_type (
str) – Interpretation of the SDE. Only'ito'is supported, by default ‘ito’.
- Returns:
The updated state
y_{n+1}with the same tree structure asy.- Return type:
PyTree
See also
sde_milstein_stepMilstein scheme (strong order 1.0).
sde_expeuler_stepExponential Euler with linearized drift.
Notes
Strong order 0.5, weak order 1.0.
Uses
dt = brainstate.environ.get_dt()and Gaussian noise scaled bysqrt(dt)viabrainstate.random.randn_likefor each leaf ofy.