# Efficient Algorithms for exponential martingales generated by SDE with jumps

**URL:** https://discourse.julialang.org/t/efficient-algorithms-for-exponential-martingales-generated-by-sde-with-jumps/127917
**Category:** Modelling & Simulations
**Tags:** question
**Created:** [April 10, 2025, 10:32am UTC](https://discourse.julialang.org/t/efficient-algorithms-for-exponential-martingales-generated-by-sde-with-jumps/127917 "2025-04-10T10:32:59Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![paolo-mgi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paolo-mgi/32/209506_2.png) [@paolo-mgi](https://discourse.julialang.org/u/paolo-mgi)
#### Post date: [April 10, 2025, 10:32am UTC](https://discourse.julialang.org/t/efficient-algorithms-for-exponential-martingales-generated-by-sde-with-jumps/127917/1 "2025-04-10T10:32:59Z")

</div>

Hello,

I am experimenting with jump processes, and in particular with stochastic diffrential equations of the form  
`dμ(t)=μ(t) λ (dν(t)−r dt )`  
where  
`dν(t)`= increment of Poisson process  
`r dt`= compensator  
The result should be an exponential martinagale, i.e. a process constant on average.  
I notice that naive implementation of the process quickly loose the martingale property probably owning to lack of statistics. Example

```julia
function mart!(du, u, p, t)
  du[1] = - p.λ * p.jump_rate * u[1]
end
function const_rate1(u,p,t)
  return p.jump_rate[1]
end  
function const_affect1!(integrator)
 v = copyto!(integrator.p.mart_tmp, integrator.u)
 integrator.u = v * (integrator.p.λ+1.0)
end  
mart_ode = ODEProblem(mart!, mu0, (0.0, tf), p)
const_jump = ConstantRateJump(const_rate1, const_affect1!)
mart_prob = JumpProblem(mart_ode, Direct(), const_jump)
ensemble_mart = EnsembleProblem(mart_prob)
sol_mart_prob = DifferentialEquations.solve(ensemble_mart, Tsit5(), EnsembleSerial(), trajectories=num_traj);

```

I would be very grateful to get advice even just reference to the numerical mathematics literature for learning how to efficiently integrate stochastic differential equations (driven by jump or point processes) whose solution enjoys the martingale property.  
Many thanks!

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [April 21, 2025, 9:04am UTC](https://discourse.julialang.org/t/efficient-algorithms-for-exponential-martingales-generated-by-sde-with-jumps/127917/2 "2025-04-21T09:04:21Z")

</div>

It should be true if the ensembe is large enough? How large of an ensemble did you use?

---

<div class="post-metadata">

### Author: ![paolo-mgi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paolo-mgi/32/209506_2.png) [@paolo-mgi](https://discourse.julialang.org/u/paolo-mgi)
#### Post date: [April 21, 2025, 11:23am UTC](https://discourse.julialang.org/t/efficient-algorithms-for-exponential-martingales-generated-by-sde-with-jumps/127917/3 "2025-04-21T11:23:11Z")

</div>

I made my tests with ensembles of 10^3 and 10^4 trajectories. Indeed, increasing the statisics improves the results. Yet the results remain far from convergence but for a region for small values of the time (t) parameter and worsen for larger value of it. I made these tests because I am interested in more complicated examples of exponential martingales. I am wondering whether some importance sampling strategy can improve the situation (unless I am doing something very silly..). It seems to me that the problem is due to the growth of the variance of an exponential martingale.  
Many thanks
