# Still do not understand difference between diagonal and scalar noise

**URL:** <https://discourse.julialang.org/t/still-do-not-understand-difference-between-diagonal-and-scalar-noise/106860>\
**Category:** New to Julia\
**Tags:** question, package, sde, differentialequation\
**Created:** [November 28, 2023, 6:06pm UTC](https://discourse.julialang.org/t/still-do-not-understand-difference-between-diagonal-and-scalar-noise/106860 "2023-11-28T18:06:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![acubed](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@acubed](https://discourse.julialang.org/u/acubed)\
**Post date:** [November 28, 2023, 6:06pm UTC](https://discourse.julialang.org/t/still-do-not-understand-difference-between-diagonal-and-scalar-noise/106860/1 "2023-11-28T18:06:41Z")

</div>

I have system of `N` coupled stochastic differential equations, that looks like

\displaystyle\frac{du\_i}{dt}=F(u\_i)+\eta\_i

here F is the function that mixes u\_i with u\_j. The quantity \eta\_i is so-called white noise with properties \langle \eta\_i(t)\rangle =0, \langle \eta\_i(t)\eta\_j(t')\rangle=2D\delta(t-t')\delta\_{ij}. I try to solve this system in Julia. I define two functions,

```julia
function deterministic_u!(du, u, p, t)
    du .= ...
end

```

```julia
function noise!(du, u, p, t)
    du = sqrt(2)
end

```

When I define `noise!` function I assume that it coresponds to D=1 case. Then I construct `SDEProblem` with this functions and a given initial conditions,

```julia
prob = SDEProblem(deterministic_u!, noise!, u0, tspan, p);

```

However, I obtain results that contradict my computations by hand. I have checked [this topic](https://discourse.julialang.org/t/white-noise-for-sdes-with-diagonal-noise/59695/8) but I still do not understand properly: when I want to add _white noise_ should I use diagonal noise or scalar noise?

---

<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:** [November 28, 2023, 6:50pm UTC](https://discourse.julialang.org/t/still-do-not-understand-difference-between-diagonal-and-scalar-noise/106860/2 "2023-11-28T18:50:23Z")

</div>

> [@acubed](#):
>
> when I want to add _white noise_ should I use diagonal noise or scalar noise?

It depends on your model. Both of those are adding white noise to the model. The question is how many independent white noise processes do you have. Do you have one white noise process, or do you have one per ODE?

For the system you describe above, it looks like you have \eta\_i and so you have one white noise per u\_i, and each of them are independent. Therefore it’s diagonal noise.

---

<div class="post-metadata">

**Author:** ![acubed](https://avatars.discourse-cdn.com/v4/letter/a/b19c9b/32.png) [@acubed](https://discourse.julialang.org/u/acubed)\
**Post date:** [November 29, 2023, 6:14pm UTC](https://discourse.julialang.org/t/still-do-not-understand-difference-between-diagonal-and-scalar-noise/106860/3 "2023-11-29T18:14:16Z")

</div>

Yes, indeed in my set-up its diagonal noise. I have tested and compared cases with diagonal and scalar noise. Thank you for this reply
