For my thesis, I’m trying to implement this model in Julia, using the
DifferentialEquations.jl package. I’ve made a rule based on a set of coupled differential equations to simulate some data. I have no previous knowledge of the subject, so bear in mind that I might have to awkwardly stumble over words to explain my problem:
function threePlusOneDimensions!(du, u, p, t) gauss = 0.2 Smax, τx, τy, τz, τf, α, β, P, S, Rₛ, L, λᵦ, λₛ = p du = (Smax /(1 + exp((Rₛ - u) / λₛ)) - u) / τx du = (P / (1 + exp((Rₛ - u) / λₛ)) + u * L - u * u - u) / τy du = (S * (α * u + β * u) - u) * gauss / τz du = (u - λᵦ * u)/ τf return nothing end
This is the rule I’m specifying. The
gauss variable should “integrate the equation as external noise ζ(t), set between –1 and 1 with Gaussian distribution.” Without the drawn value, it is very fast. As soon as I add the external noise term, it slows down tremendously. How do I implement this in an idiomatic manner? I copied the full text from the paper explaining the third equation below.
Equation 3: Modeling of perceived environment
The third equation refers to the environment (or external world) perceived by a patient, modeled by the variable z (Equation 3), which evolves with a time constant τz. It depends on the overal sensitivity level S, and the joint effects of symptoms x and the potentiation y respectively pondered by factor α and β. The factors α and β may be positive or negative depending on the type of psychiatric disease considered. The perceived environment integrates the equation as external noise ζ(t), set between –1 and 1 with Gaussian distribution. The release occurs with an exponential decay (−z).
This part of the paper is also relevant:
Thirdly, the rate of the noise ζ(t) is chosen at 0.01, meaning that the perceived environment variable z changes every 0.01 days (noise will be generated every 14.4 min). It is a compromise between the duration of variability of the symptoms of psychiatric disorders and their environment (i.e., considering a psychological state change every 14.4 min). In other words, the model provides a smoothness of 14.4 min, i.e., informs about potential changes in its variables approximately every quarter of an hour.
How do I do this idiomatically, so that the package properly recognizes that there is a random term? I’ve tried doing it with rand() or through drawing from a distribution, but I cannot do so according to the specifications in the paper without it slowing down tremendously. I wanted to solve it myself, and also tried many other things, asked my supervisors for help as well, but I haven’t been able to proceed for some time now.