You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/tutorials/sde_example.md
+30-34Lines changed: 30 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -142,49 +142,45 @@ In general, a system of SDEs
142
142
du = f(u,p,t)dt + g(u,p,t)dW,
143
143
```
144
144
145
-
where `g` is now a matrix of values, is numerically integrated in the
146
-
same way as ODEs. A common scenario is when we have diagonal noise, which
147
-
is the default for DifferentialEquations.jl. Physically this means that
148
-
every variable in the system gets a different random kick. Consequently, `g` is a
149
-
diagonal matrix and we can handle this in a simple manner by defining
150
-
the deterministic part `f(du,u,p,t)` and the stochastic part
151
-
`g(du2,u,p,t)` as in-place functions.
152
-
153
-
Consider for example a stochastic variant of the Lorenz equations, where we introduce a
154
-
simple additive noise to each of `x,y,z`, which is simply `3*N(0,dt)`. Here, `N` is the normal
155
-
distribution and `dt` is the time step. This is done as follows:
145
+
where `u` is now a vector of variables, `f` is a vector, and `g` is a matrix, is numerically integrated in the same way as ODEs. A common scenario, which is the default for DifferentialEquations.jl, is that every variable in the system gets a different random kick. This is the case when `g` is a diagonal matrix. Correspondingly, we say that we have a diagonal noise.
146
+
147
+
We handle this in a simple manner by defining the deterministic part `f!(du,u,p,t)` and the stochastic part
148
+
`g!(du2,u,p,t)` as in-place functions, but note that our convention is that the function `g!` only defines and modifies the diagonal entries of `g` matrix.
149
+
150
+
As an example, we consider a stochastic variant of the Lorenz equations, where we add to each of `u₁, u₂, u₃` their own simple noise `3*N(0,dt)`. Here, `N` is the normal distribution and `dt` is the time step. This is done as follows:
156
151
157
152
```@example sde2
158
153
using DifferentialEquations
159
154
using Plots
160
-
function lorenz!(du, u, p, t)
155
+
156
+
function f!(du, u, p, t)
161
157
du[1] = 10.0 * (u[2] - u[1])
162
158
du[2] = u[1] * (28.0 - u[3]) - u[2]
163
159
du[3] = u[1] * u[2] - (8 / 3) * u[3]
164
160
end
165
161
166
-
function σ_lorenz!(du, u, p, t)
162
+
function g!(du, u, p, t) # It actually represents a diagonal matrix [3.0 0 0; 0 3.0 0; 0 0 3.0]
0 commit comments