integrate_stochastic#
- bayesflow.utils.integrate_stochastic(drift_fn: Callable, diffusion_fn: Callable, state: Dict[str, int | float | Tensor], start_time: int | float | Tensor, stop_time: int | float | Tensor, seed: SeedGenerator, steps: int | Literal['adaptive'] = 100, method: str = 'euler_maruyama', min_steps: int = 50, max_steps: int = 1000, score_fn: Callable = None, corrector_steps: int = 0, noise_schedule=None, step_size_factor: int | float | Tensor = 0.01, **kwargs) Dict[str, int | float | Tensor][source]#
Integrate a stochastic differential equation from
start_timetostop_time.This function dispatches to either fixed-step or adaptive-step integration logic, depending on the selected integration
methodand the value ofsteps.- Parameters:
- drift_fncallable
Function computing the drift term of the SDE. It should accept the current state and time as inputs.
- diffusion_fncallable
Function computing the diffusion term of the SDE. It should accept the current state and time as inputs.
- stateStateDict
Dictionary containing the initial state of the system.
- start_timearray-like
Starting time for integration.
- stop_timearray-like
Ending time for integration.
- seedkeras.random.SeedGenerator
Random seed generator used for noise generation.
- stepsint or {‘adaptive’}, optional
Number of integration steps for fixed-step integration, or
'adaptive'to enable adaptive step sizing. Adaptive integration is only supported by the'shark'method. Default is100.- methodstr, optional
Integration method to use (e.g.,
'euler_maruyama'or'shark'). Default is'euler_maruyama'.- min_stepsint, optional
Minimum number of steps for adaptive integration. Default is
50.- max_stepsint, optional
Maximum number of steps for adaptive integration. Noise is pre-generated up to this number of steps, which may increase memory usage. Default is
1000.- score_fncallable, optional
Score function used for predictor–corrector sampling. If
None, no corrector step is applied.- corrector_stepsint, optional
Number of corrector steps applied after each predictor step. Default is
0.- noise_scheduleobject, optional
Noise schedule object used to compute
alpha_tduring the corrector step. Required ifcorrector_steps > 0.- step_size_factorarray-like, optional
Scaling factor applied to the corrector step size. Default is
0.01.- **kwargs
Additional keyword arguments passed to the underlying step function.
- Returns:
- StateDict
Final state dictionary after integration.