torchebm.integrators.euler_maruyama ¶
Euler-Maruyama integrator.
EulerMaruyamaIntegrator ¶
Bases: BaseSDERungeKuttaIntegrator
Euler-Maruyama integrator for Itô SDEs and ODEs.
The SDE form is:
\[ \mathrm{d}x = f(x,t)\,\mathrm{d}t + \sqrt{2D(x,t)}\,\mathrm{d}W_t \]
When diffusion is omitted, this reduces to the Euler method for ODEs.
Update rule:
\[ x_{n+1} = x_n + f(x_n, t_n)\Delta t + \sqrt{2D(x_n,t_n)}\,\Delta W_n \]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device | Optional[device] | Device for computations. | None |
dtype | Optional[dtype] | Data type for computations. | None |
atol | float | Absolute tolerance for adaptive stepping. | 1e-06 |
rtol | float | Relative tolerance for adaptive stepping. | 0.001 |
max_steps | int | Maximum number of steps before raising | 10000 |
safety | float | Safety factor for step-size adjustment (< 1). | 0.9 |
min_factor | float | Minimum step-size shrink factor. | 0.2 |
max_factor | float | Maximum step-size growth factor. | 10.0 |
max_step_size | float | Maximum absolute step size during adaptive integration. | float('inf') |
norm | Optional[Callable[[Tensor], Tensor]] | Callable | None |
Example
Source code in torchebm/integrators/euler_maruyama.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |