Hey, I am trying to simulate with the use of JumpProcesses.jl the following stochastic differential equation:
dX_t = -X_tdt + dN_t .
Do you know, if there is any straightforward way of defining the f (drift) function in this case? If you go for the following:
function f(du, u, p, t)
du[1] = -u[1]
end
then as far as I understand your process has the following form:
dX_t = \exp(-X_t)dt + dN_t .
No, that would put your equation in the right form.
1 Like
Thank you for pointing this.
I am a bit confused since all the paths I get when simulating this process are positive:
For the comparison, using the jumpdiff library from python and simulating the same process, the paths look like this:
Is there any reason, why Julia’s path gives only positive value (some shifting etc.), or is there something else wrong?
I am using the following code for the Julia path:
using DifferentialEquations, Plots, JumpProcesses
timestep = Float64(0.05)
t = range(0, timestep, length=100)
function f(du, u, p, t)
du[1] = -u[1]
end
rate(u, p, t) = 1.0
function affect!(integrator)
integrator.u[1] += 1
nothing
end
jump = ConstantRateJump(rate, affect!)
prob = ODEProblem(f, [0.0], (10.0, 100.0))
jump_prob = JumpProblem(prob, Direct(), jump)
sol = solve(jump_prob, Tsit5(), saveat=timestep)
plot(sol)
Dan
June 5, 2024, 9:09pm
4
The jump amplitude parameter in Python jumpdiff library is the standard deviation of a Gaussian distributed jump N(0,sigma^2)
and as such can take both negative and positive values.
In the Julia code:
function affect!(integrator)
integrator.u[1] += 1
nothing
end
the jump is a +1 jump only (at a specified rate). To get the same as the Python effect use:
function affect!(integrator)
integrator.u[1] += randn()
nothing
end
1 Like
Thanks, that makes much more sense now!