# SDE simulation using DifferentialEquations.jl SDE solver RKMilGeneral

**URL:** <https://discourse.julialang.org/t/sde-simulation-using-differentialequations-jl-sde-solver-rkmilgeneral/88312>\
**Category:** Modelling & Simulations\
**Tags:** sde, plot, differentialequation\
**Created:** [October 5, 2022, 9:26pm UTC](https://discourse.julialang.org/t/sde-simulation-using-differentialequations-jl-sde-solver-rkmilgeneral/88312 "2022-10-05T21:26:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Max\_Beez](https://avatars.discourse-cdn.com/v4/letter/m/7bcc69/32.png) [@Max\_Beez](https://discourse.julialang.org/u/Max_Beez)\
**Post date:** [October 5, 2022, 9:26pm UTC](https://discourse.julialang.org/t/sde-simulation-using-differentialequations-jl-sde-solver-rkmilgeneral/88312/1 "2022-10-05T21:26:23Z")

</div>

I am simulating an SDE and using scatter! to plot the results.

I set

> dt = 0.1 with timespan 0.0 to 1.0,

then if use EM() as the SDE solver method I get 10 equally spaced (in-time) scatter points on the plot.

However, if I use RKMilGeneral for the same purposes I end up with anywhere from 12-19 points plotted, that is 11 to 18 unevenly spaced segments, on the resultant plot.

I am curious as to why this is.

---

<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:** [October 6, 2022, 2:01am UTC](https://discourse.julialang.org/t/sde-simulation-using-differentialequations-jl-sde-solver-rkmilgeneral/88312/2 "2022-10-06T02:01:23Z")

</div>

> [@Max\_Beez](#):
>
> I am curious as to why this is.

With adaptive time stepping, `dt` is just the initial dt.

[https://diffeq.sciml.ai/stable/basics/common\_solver\_opts/#Basic-Stepsize-Control](https://diffeq.sciml.ai/stable/basics/common_solver_opts/#Basic-Stepsize-Control)

> - `dt`: Sets the initial stepsize. This is also the stepsize for fixed timestep methods. Defaults to an automatic choice if the method is adaptive.

---

<div class="post-metadata">

**Author:** ![Max\_Beez](https://avatars.discourse-cdn.com/v4/letter/m/7bcc69/32.png) [@Max\_Beez](https://discourse.julialang.org/u/Max_Beez)\
**Post date:** [October 6, 2022, 2:09am UTC](https://discourse.julialang.org/t/sde-simulation-using-differentialequations-jl-sde-solver-rkmilgeneral/88312/3 "2022-10-06T02:09:46Z")

</div>

Ah okay, under RKMilGeneral it doesn’t say adaptive but I should be familiar enough to know that is the case, is there anyway I can force this to have fixed time-step? I suppose if I need fixed I should be sticking with another method.

---

<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:** [October 6, 2022, 2:20am UTC](https://discourse.julialang.org/t/sde-simulation-using-differentialequations-jl-sde-solver-rkmilgeneral/88312/4 "2022-10-06T02:20:55Z")

</div>

> [@Max\_Beez](#):
>
> Ah okay, under RKMilGeneral it doesn’t say adaptive

Any method is adaptive by default. The documentation mentions it the other way around: there’s an explicit mention to any method that is fixed time step only.

> - `EM`- The Euler-Maruyama method. Strong Order 0.5 in the Ito sense. Has an optional argument `split=true` for controlling step splitting. When splitting is enabled, the stability with large diffusion eigenvalues is improved. Can handle all forms of noise, including non-diagonal, scalar, and colored noise. Fixed time step only.†

> [@Max\_Beez](#):
>
> is there anyway I can force this to have fixed time-step?

[https://diffeq.sciml.ai/stable/basics/common\_solver\_opts/#Basic-Stepsize-Control](https://diffeq.sciml.ai/stable/basics/common_solver_opts/#Basic-Stepsize-Control)

> - `adaptive`: Turns on adaptive timestepping for appropriate methods. Default is true.

So just use `adaptive = false`.
