SciML / StochasticDiffEq.jl

Solvers for stochastic differential equations which connect with the scientific machine learning (SciML) ecosystem
Other
245 stars 66 forks source link

noise_rate_prototype for scalar noise #490

Closed rmsrosa closed 2 years ago

rmsrosa commented 2 years ago

When solving a system with scalar noise, what would be the proper way to set noise_rate_prototype?

It works if I set the noise explicitly, like noise = WienerProcess(0.0, 0.0), but I couldn't make it work with neither noise_rate_prototype = 0.0, nor noise_rate_prototype = () nor noise_rate_prototype = (1,).

Here is an MWE taking from the example in the SDE Tutorial:

f(du,u,p,t) = (du .= u)
g(du,u,p,t) = (du .= u)
u0 = rand(4,2)

prob = SDEProblem(f, g, u0, (0.0,1.0), noise_rate_prototype = 1.0)

With that, I get

julia> sol = solve(prob, LambaEM())
ERROR: MethodError: no method matching getindex(::Float64, ::Int64, ::Colon)

Here is my info:

(sde) pkg> st
      Status `~/temp/sde/Project.toml`
  [789caeaf] StochasticDiffEq v6.51.0

julia> versioninfo()
Julia Version 1.7.2
Commit bf53498635 (2022-02-06 15:21 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin19.5.0)
  CPU: Apple M1 Pro
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, westmere)
Environment:
  JULIA_NUM_THREADS = 8
ChrisRackauckas commented 2 years ago

See https://diffeq.sciml.ai/stable/tutorials/sde_example/#Example-3:-Systems-of-SDEs-with-Scalar-Noise . When doing scalar noise, you don't do noise_rate_prototype and its form is then just like diagonal noise except the perturbation is the same to each term. I'm not sure how else you could reasonably define it.