JuliaDynamics / CriticalTransitions.jl

A Julia package for critical transitions in dynamical systems with time-dependent forcing
https://juliadynamics.github.io/CriticalTransitions.jl/dev/
MIT License
26 stars 3 forks source link

Correlated SDE test #113

Open oameye opened 2 months ago

oameye commented 2 months ago
using DynamicalSystemsBase, StochasticDiffEq, DiffEqNoiseProcess
using CairoMakie

ρ = 0.3
Σ = [1 ρ; ρ 1]
t0 = 0.0; W0 = zeros(2); Z0 = zeros(2);
W = CorrelatedWienerProcess(Σ, t0, W0, Z0)

zero!(du, u, p, t) = du .= 0.0 # deterministic part
sde = CoupledSDEs(zero!, idfunc!, zeros(2), nothing, σ; noise=W)
Y, t = trajectory(sde, 1000.0, zeros(2))

fig = Figure()
ax = Axis(fig[1,1], limits = (-0.5,0.5, -0.5, 0.5))
scatter!(ax, diff(Matrix(Y)', dims=2))
fig

Check that values are correlated.

reykboerner commented 2 days ago

Now in v0.4.0, writing sde = CoupledSDEs(zero!, zeros(2); noise_process = W) returns the error

ArgumentError: CoupledSDEs does not support correlation between noise processes through DiffEqNoiseProcess.jl interface. Instead, use the `covariance` kwarg of `CoupledSDEs`.

This is what we want so that we can extract the covariance_matrix later, right? But we should note it in the docs.

oameye commented 2 days ago

Yes exactly, in Sciml their are multiple ways. We opted to only have one, to be concistent. Good idea!