@@ -290,7 +290,60 @@ basins, attractors = basins_of_attraction(mapper; show_progress = false)
290
290
291
291
heatmap_basins_attractors ((xg, yg), basins, attractors)
292
292
293
- # One last thing to highlight in this short overview are the interactive GUI apps one
293
+ # ## Stochastic systems
294
+
295
+ # DynamicalSystems.jl has some support for stochastic systems
296
+ # in the form of Stochastic Differential Equations (SDEs).
297
+ # Just like `CoupledODEs`, one can make `CoupledSDEs`!
298
+ # For example here is a stochastic version of a FitzHugh-Nagumo model
299
+
300
+ using StochasticDiffEq # load extention for `CoupledSDEs`
301
+
302
+ function fitzhugh_nagumo (u, p, t)
303
+ x, y = u
304
+ ϵ, β, α, γ, κ, I = p
305
+ dx = (- α * x^ 3 + γ * x - κ * y + I) / ϵ
306
+ dy = - β * y + x
307
+ return SVector (dx, dy)
308
+ end
309
+ p = [1. ,3. ,1. ,1. ,1. ,0. ]
310
+ sde = CoupledSDEs (fitzhugh_nagumo, zeros (2 ), p; noise_strength = 0.05 )
311
+
312
+ # In this particular example the SDE noise is white noise (Wiener process)
313
+ # with strength (σ) of 0.05. See the documentation of `CoupledSDEs` for alternatives.
314
+
315
+ # In any case, in DynamicalSystems.jl all dynamical systems are part of the same
316
+ # interace, stochastic or not. As long as the algorithm is not influenced by stochasticity,
317
+ # we can apply it to `CoupledSDEs` just as well. For example, we can study multistability
318
+ # in a stochastic system. In contrast to the previous example of the Henon map,
319
+ # we have to use an alternative algorithm, because `AttractorsViaRecurrences`
320
+ # only works for deterministic systems. So instead we'll use `AttractorsViaFeaturizing`:
321
+
322
+ featurizer (X, t) = X[end ]
323
+
324
+ mapper = AttractorsViaFeaturizing (sde, featurizer; Ttr = 200 , T = 10 )
325
+
326
+ xg = yg = range (- 1 , 1 ; length = 101 )
327
+
328
+ sampler, _ = statespace_sampler ((xg, yg))
329
+
330
+ fs = basins_fractions (mapper, sampler)
331
+
332
+ # and we can see the stored "attractors"
333
+
334
+ attractors = extract_attractors (mapper)
335
+ fig, ax = scatter (attractors[1 ])
336
+ scatter! (attractors[2 ])
337
+ fig
338
+
339
+ # The mathematical concept of attractors
340
+ # doesn't translate trivially to stochastic systems but thankfully
341
+ # this system has two fixed point attractors that are only mildly perturbed
342
+ # by the noise.
343
+
344
+ # ## Interactive GUIs
345
+
346
+ # A particularly useful feature are interactive GUI apps one
294
347
# can launch to examine a `DynamicalSystem`. The simplest is [`interactive_trajectory_timeseries`](@ref).
295
348
# To actually make it interactive one needs to enable GLMakie.jl as a backend:
296
349
0 commit comments