Hi,
Apologies for not having a more informative title. I’m having a little trouble solving a 2-dimensional SDE in DifferentialEquations.jl. My current code is
using DifferentialEquations, ForwardDiff
# Solve Chemical Langevin Equation SDE
# dX = α(X) dt + √β(x) dW
S = [ 1 -1 0; 0 1 -1]
function h(x, c)
return h = [ c[1] * x[1]; c[2] * x[1] * x[2]; c[3] * x[2]]
end
function α(x, c)
return dx = S * h(x, c)
end
function β(x, c)
return σx = S * Diagonal(h(x, c)) * transpose(S)
end
function sqrtβ(x, c)
return sqrt(β(x, c))
end
x0 = [ 70 ; 80 ]
tspan = (0.0, 50.0)
c = [ 1.0, 0.005, 0.6 ]
lotvol_CLE_SDE = SDEProblem(α, sqrtβ, x0, tspan, c)
CLE_sol = solve(lotvol_CLE_SDE)
which, upon running the final line, returns the error
> MethodError: no method matching α(::Array{Float64,1}, ::Array{Float64, 1}, ::Float64)
and I can’t totally make sense of this. Is the issue to do with e.g.
- how I’ve written the drift function
- how I’ve passed the drift function to the SDE problem
- how I’ve passed the parameters
c
to the problem
or something else entirely?
Separately, the SDE in question has a multiplicative, non-diagonal noise structure. I’m not sure whether this is causing the problem (the error I’m receiving doesn’t seem to suggest so), but I wanted to get a sanity check on whether I’ve written it sensibly. The examples here were useful, but are phrased in slightly different terms to what I’m used to.