Module Jera.Sde
Stochastic differential equations.
A problem is a drift f t y, the deterministic part of the derivative; a diffusion, applied to a Brownian increment as diffusion t y dw and linear in dw; and a Brownian path. The method fixes the calculus: Itô or Stratonovich.
Methods
type tThe type for methods.
euler_maruyama is the Euler–Maruyama method, Itô, for any noise: strong order 1/2. One drift and one diffusion evaluation per step.
milstein is the derivative-free Milstein method (Kloeden and Platen, 1992, §11.1), Itô: strong order 1 for diagonal noise, and 1/2 otherwise. Diagonal noise has the state one tensor of the path's shape, and diffusion t y dw the product of dw with a tensor whose component i depends on y_i only. One drift and three diffusion evaluations per step.
sra1 is Rößler's (2010) SRA1, for additive noise, where the diffusion does not depend on the state: strong order 3/2, reading the Lévy area; 1/2 otherwise. Two drift and two diffusion evaluations per step.
reversible_heun is the reversible Heun method (Kidger, Foster, Li and Lyons, 2021), Stratonovich: strong order 1/2, and 1 for additive noise. It carries a second state, so each step costs one drift and two diffusion evaluations.
Marches
val march :
('y, 'd) Nx.Ptree.t ->
t ->
steps:int ->
drift:((float, 't, 'd) Nx.t -> 'y -> 'y) ->
diffusion:((float, 't, 'd) Nx.t -> 'y -> (float, 't, 'd) Nx.t -> 'y) ->
('t, 'd) Brownian.t ->
at:(float, 't, 'd) Nx.t ->
'y ->
'ymarch y m ~steps ~drift ~diffusion w ~at y0 is the state at each time of at, stacked on a new leading axis of each leaf, y0 first, along the path w. The interval from at.(i) to at.(i+1) takes steps steps: step j starts at at.(i) + j h with h = (at.(i+1) − at.(i)) / steps, or at at.(i+1) where that rounds past it. Every step but the last has size h; the last has size at.(i+1) minus its start, never negative, and ends at at.(i+1) itself. A step draws its increment over the path from its start to the next step's start, and queries the path once, at that end. drift t y is the deterministic field; diffusion t y dw is g t y applied to dw, of w's shape and the times' dtype, and must be linear in dw; it casts dw for leaves of another dtype. Reverse mode keeps one state per time of at and recomputes each interval while it reverses it; the derivative is the composition's, in the initial state and every tracked value the drift and diffusion read. A compiled function takes w as an argument, described by Nx.Ptree.v Brownian.walk.
Raises Invalid_argument if steps < 1, if at is not a non-empty 1-D tensor, through Nx.check if at is not strictly increasing or leaves w's interval, and if the drift or the diffusion returns a value of another structure, dtype or shape than its state.