# Understanding the use of \`SDEFunction\`

**URL:** https://discourse.julialang.org/t/understanding-the-use-of-sdefunction/111559
**Category:** Modelling & Simulations
**Tags:** diffeq, sde, differentialequation
**Created:** [March 13, 2024, 10:33am UTC](https://discourse.julialang.org/t/understanding-the-use-of-sdefunction/111559 "2024-03-13T10:33:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![james](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@james](https://discourse.julialang.org/u/james)
#### Post date: [March 13, 2024, 10:33am UTC](https://discourse.julialang.org/t/understanding-the-use-of-sdefunction/111559/1 "2024-03-13T10:33:07Z")

</div>

I am learning how to work with SDEs in julia and am a bit confused:  
In the [documentation](https://docs.sciml.ai/DiffEqDocs/dev/types/sde_types/#SciMLBase.SDEProblem), both of `SDEProblem`’s constructors take two functions f,g as their first two arguments, where f should be the drift and g the noise term. One of the constructors requires f to be of type `SDEFunction`. That makes sense to me.  
The strange part is: [SDEFunction](https://docs.sciml.ai/DiffEqDocs/dev/types/sde_types/#SciMLBase.SDEFunction) requires in its only constructor _both_ the drift term f and noise term g:

```julia
SDEFunction{iip,specialize}(f,g; [...])

```

That does not make sense to me – if we use the first constructor of `SDEProblem`:  
`SDEProblem(f::SDEFunction,g,u0,tspan,p=NullParameters();noise=WHITE_NOISE,noise_rate_prototype=nothing)`  
we would input g as both the 2nd argument of `SDEProblem` and in the input of the first argument of `SDEProblem`, since it is of type `SDEFunction`.

To make things more confusing, the [first-steps SDE tutorial](https://docs.sciml.ai/DiffEqDocs/stable/tutorials/sde_example/#Using-Higher-Order-Methods) does not provide g as parameter in the construction of the SDEProblem – contradicting the two contstructors in the documentation of [SDEProblem](https://docs.sciml.ai/DiffEqDocs/dev/types/sde_types/#SciMLBase.SDEProblem).

```julia
ff = SDEFunction(f, g, analytic = f_analytic)
prob = SDEProblem(ff, u₀, (0.0, 1.0))

```

What am I not getting about this SDEFunction?

---

<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: [March 16, 2024, 9:10am UTC](https://discourse.julialang.org/t/understanding-the-use-of-sdefunction/111559/2 "2024-03-16T09:10:56Z")

</div>

> [@james](#):
>
> That does not make sense to me – if we use the first constructor of `SDEProblem`:  
> `SDEProblem(f::SDEFunction,g,u0,tspan,p=NullParameters();noise=WHITE_NOISE,noise_rate_prototype=nothing)`

That’s just a typo in the docstring. It should be `SDEProblem(f::SDEFunction,u0,tspan,p=NullParameters();noise=WHITE_NOISE,noise_rate_prototype=nothing)`. I assume that solves the rest of your issues.

The next doc build should include the fix.

---

<div class="post-metadata">

### Author: ![james](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@james](https://discourse.julialang.org/u/james)
#### Post date: [March 16, 2024, 12:33pm UTC](https://discourse.julialang.org/t/understanding-the-use-of-sdefunction/111559/3 "2024-03-16T12:33:38Z")

</div>

It does – many thanks.
