 # Variable rate jumps diffeq?

I’m trying to get a variable rate jump to work. I am using

``````
## jump in price
#rate1(u,p,t) = λ0 # constant jump rate
rate1(u,p,t) = λ0.*exp(u) # volatility dependent jump rate
# jump is normal with st. dev. equal to λ1 times current st. dev.
affect1!(integrator) = (integrator.u = integrator.u.+randn(size(integrator.u)).*λ1.*exp(integrator.u./2.0))

# this works:
jump1 = ConstantRateJump(rate1,affect1!)
# this does not
#jump1 = VariableRateJump(rate1,affect1!)
jump_prob = JumpProblem(prob,Direct(), jump1)

``````

The rate, rate1, depends on the second integrator, so I understand that it is a variable rate jump. However, I get a dimension error if I try to specify it as variable rate (jump1, commented out). The solver gives a solution if I specify it as constant rate.

Am I making an error in the syntax for a variable rate jump?
Thanks!

Here’s the environment, and the whole file, if it helps

``````(JD) pkg> st
Status `~/Desktop/JD/Project.toml`
[a077e3f3] DiffEqProblemLibrary v4.8.0
[0c46a032] DifferentialEquations v6.14.0 `https://github.com/SciML/DifferentialEquations.jl.git#master`
[91a5bcdd] Plots v0.29.9
[e6cf234a] RandomNumbers v1.4.0

(JD) pkg>

``````
``````using DifferentialEquations, Plots

function MyProblem(μ0,μ1,κ,α,σ,ρ,u0,tspan)
f = function (du,u,p,t)
du = μ0 + μ1*(u-α)/σ # drift in prices
du = κ*(α-u) # mean reversion in shocks
end
g = function (du,u,p,t)
du = exp(u/2.0)
du = σ
end
Γ = [1 ρ;ρ 1] # Covariance Matrix
noise = CorrelatedWienerProcess!(Γ,tspan,zeros(2),zeros(2))
sde_f = SDEFunction{true}(f,g)
SDEProblem(sde_f,g,u0,tspan,noise=noise)
end

μ0 = 0.0
μ1 = 0.0
κ = 0.05
α = 0.2
σ = 0.2
ρ = -0.7
λ0 = 2.0
λ1 = 3.0
u0 = [0;α]
dt = 0.01
prob = MyProblem(μ0, μ1, κ, α, σ, ρ, u0, (0.0,1000.0))

## jump in price
#rate1(u,p,t) = λ0 # constant jump rate
rate1(u,p,t) = λ0.*exp(u) # volatility dependent jump rate
# jump is normal with st. dev. equal to λ1 times current st. dev.
affect1!(integrator) = (integrator.u = integrator.u.+randn(size(integrator.u)).*λ1.*exp(integrator.u./2.0))

# this works:
jump1 = ConstantRateJump(rate1,affect1!)
# this does not
#jump1 = VariableRateJump(rate1,affect1!)
jump_prob = JumpProblem(prob,Direct(), jump1)