Reusing NoiseProcess in StochasticDiffEq

I am trying to use the same NoiseProcess in two different SDE integrations. I don’t mean to just use the same type of noise, but the same values as well (and potentially values in intermediate times obtained via the bridge function). I can get the NoiseProcess from the first integration by passing get_noise=true in the first solve call:

using DifferentialEquations
using Plots

function f!(du, u, p, t)
    du[1] = u[1]
end

function g!(du, u, p, t)
    du[1] = 0.1u[1]
end

tspan = (0.0, 10.0)
u0 = [1.0]

prob = SDEProblem(f!, g!, u0, tspan)

sol = solve(prob, save_noise=true)
# sol.W is the noise process

But I can’t find a way to use this noise in another solve. I would like something like this:
prob2 = SDEProblem(f!, g!, u0, tspan, noise=sol.W, alg=SomeOtherAlg) but the noise argument seems to be meant for the noise type, not specific noise values.
E.g., running the following code (after I ran the first) results in non-overlapping graphs:

plot(sol.t, sol[1, :])

prob2 = SDEProblem(f!, g!, u0, (tspan), noise=sol.W)
sol = solve(prob2, save_noise=true)
plot!(sol.t, sol[1, :])

I think you’re looking for NoiseWrapper?

2 Likes

That’s exactly it! Thanks!
Also, in case anyone else encounters these problems, note that inputting the NoiseWrapper to solve changes the default solving algorithm, so you need to specify that as well to reproduce the same results.

1 Like