SciML / DiffEqNoiseProcess.jl

A library of noise processes for stochastic systems like stochastic differential equations (SDEs) and other systems that are present in scientific machine learning (SciML)
https://docs.sciml.ai/DiffEqNoiseProcess/stable/
Other
63 stars 29 forks source link

Brownian bridge not working properly after first solve #131

Closed rmsrosa closed 1 year ago

rmsrosa commented 1 year ago

If I solve an SDE with a Brownian bridge noise, the first solve is okay, but subsequent solves seem to be of a regular Wiener process, without bridging. I don't know yet where is the problem. Just registering the issue for now.

This happens in either the current versions DiffEqNoiseProcess v5.14.1 and StochasticDiffEq v6.55.0 or in the older versions DiffEqNoiseProcess v5.12.0, StochasticDiffEq v6.51.0.

MWE:

using StochasticDiffEq, DiffEqNoiseProcess

f = (u, p, t) -> 1.0
g = (u, p, t) -> 0.2
tspan = (0.0, 1.0)
x0 = 1.0

W = BrownianBridge(0.0, 1.0, 0.0, 1.0, nothing, nothing)

prob = SDEProblem(f, g, x0, tspan, noise = W, save_noise = true)

I get

julia> sol = solve(prob, EM(), dt=1/10); sol.W
t: 11-element Vector{Float64}:
 0.0
 0.1
 ⋮
 0.8999999999999999
 0.9999999999999999
u: 11-element Vector{Float64}:
 0.0
 0.26543511070295556
 ⋮
 1.0863290648610924
 1.0

julia> sol = solve(prob, EM(), dt=1/10); sol.W
t: 11-element Vector{Float64}:
 0.0
 0.1
 ⋮
 0.8999999999999999
 0.9999999999999999
u: 11-element Vector{Float64}:
  0.0
 -0.08632906486109237
  ⋮
 -0.11088269055897593
 -0.12475534714376024
rmsrosa commented 1 year ago

This is apparently due to W.S₁ being emptied at some point along the solve, and that is the only place where the info about the last point of the bridge is stored. Problem is that I haven't still understood the role of W.S₁ and W.S₂.

rmsrosa commented 1 year ago

fixed by #132