utils.solver.euler_maruyama_method
utils.solver.euler_maruyama_method(
f,
t_span,
y0,
dt,
si=None,
noise_func=None,
rng=None,
args=(),
post_step=None,
)Fixed-step Euler-Maruyama integrator for stochastic differential equations.
Solves:
dy = f(t, y) dt + noise_func(t, y) dW
where dW is a Wiener increment with variance dt.
Parameters
f : callable-
Drift function with signature
f(t, y, *args). t_span : tuple of float-
(t0, tf)integration bounds. y0 : array -like-
Initial state vector.
dt : float-
Integration timestep.
si : float or None = None-
Sampling interval — output is saved every
sitime units, with Wiener increments accumulated across the intervening sub-steps (no interpolation). Must be an integer multiple ofdt. Defaults todt(every step is saved). noise_func : callable or None = None-
Diffusion function with signature
noise_func(t, y), returning a vector of per-state diffusion scales. IfNone, the stochastic term is zero and deterministic Euler is recovered. rng : numpy.random.Generator or None = None-
Random generator for Wiener increments. A fresh generator is created if
None. args : tuple = ()-
Extra positional arguments forwarded to
f. post_step : callable or None = None-
Optional hook called after each accepted sub-step with signature
post_step(t, y) -> y. The returned array replaces the current state, allowing post-step corrections (e.g. state nudging).
Returns
solution : Solution-
Object with attributes
t(time axis) andy(state trajectory).
Raises
: ValueError-
If
t_spanis invalid,siis not an integer multiple ofdt,t_spanlength is not an integer multiple ofsi, ornoise_funcreturns a vector whose shape does not match the state vector.