StochasticDiffEq.jl
StochasticDiffEq.jl copied to clipboard
Allow seeding `SDEProblems` with e.g. StableRNGs
For JumpProcesses's JumpProblem
s you can do
using JumpProcesses, StableRNGs
rng = StableRNG(12345)
jprob = JumpProblem(no_param_network, dprob, Direct(); rng = rng)
sol1 = solve(jprob, SSAStepper())
sol2 = solve(jprob, SSAStepper())
sol3 = solve(jprob, SSAStepper())
and now, while sol1
, sol2
, and sol3
are different, they will yield reproducibly the same result each time I rerun the above snippet (useful to e.g. remove any randomness from tests). Note, this si different from setting a seed
, where if I do:
using JumpProcesses, StableRNGs
jprob = JumpProblem(no_param_network, dprob, Direct(); seed = 1234)
sol1 = solve(jprob, SSAStepper())
sol2 = solve(jprob, SSAStepper())
sol3 = solve(jprob, SSAStepper())
sol1
, sol2
, and sol3
will be identical.
StochasticDiffEq does not have a feature like this (and is only able to set seed
s, however, it would be useful.
It is possible to partially circumvent this by setting different seed
s for each sol (potentially depending on the StableRNG). However, long-term, being able to provide a stable rng to a SDEProblem
directly would be ideal.
I think the bigger issue here is providing a simple way for users to set the rng used internally, i.e. via the problem or solve call, which would also fix this issue.