I need to build a list with the values of the parameter $\gamma = \mu/a$ and the standard deviation of the following process,

a = .3;
μ = n/10;
c = .2;
σ = 0.1;
proc = ItoProcess[{\[DifferentialD]s[t] == -a s[t] i[
       t] \[DifferentialD]t, \[DifferentialD]i[
       t] == (a s[t] i[t] - μ i[t] + 
         c (1 - s[t] - i[t]) i[t]) \[DifferentialD]t + σ i[
        t] \[DifferentialD]W[t]}, {s[t], i[t]}, {{s, i}, {0.3, 0.7}}, 
   t, W \[Distributed] WienerProcess[0, 1]];

aa = ParallelTable[RandomFunction[proc, {0, 3000, 0.5}, 10], {100}]; //
   AbsoluteTiming // First
sol2 = TemporalData[
  Join @@ Through[aa["ValueList"]], {aa[[1]]["Times"]}]

The table should have values of μ/a (where n varies as loop index) and the standard deviation of the process. I've tried to build a loop using "Do" and "For" to evaluate the process for each index n and saves the values of μ/a and the standard deviation in a table, but i doesn't work. How could I do that task?

Thanks in advance!

  • $\begingroup$ If you want a table, why would you use Do rather than Table? $\endgroup$ – John Doty Sep 11 '18 at 18:38
  • $\begingroup$ I had not thought in this possibility... $\endgroup$ – Herr Schrödinger Sep 11 '18 at 18:41

Better write the process as function of its parameters and make the iteration variable n explicit:

a = .3;
c = .2;
σ = 0.1;
proc[μ_, σ_, a_, c_] := ItoProcess[{
    \[DifferentialD]s[t] == -a s[t] i[t] \[DifferentialD]t,
    \[DifferentialD]i[t] == (a s[t] i[t] - μ i[t] + c (1 - s[t] - i[t]) i[t]) \[DifferentialD]t + σ i[t] \[DifferentialD]W[t]
   {s[t], i[t]}, {{s, i}, {0.3, 0.7}}, t, 
   W \[Distributed] WienerProcess[0, 1]

aa = ParallelTable[
     RandomFunction[proc[n/10, σ, a, c], {0, 300, 0.15},10], 
     {n, 1, 100}

I reduced the stepsize and the time horizon because Mathematica issued several overflow error. This is more a problem with the mathematical model of this process (it tends to blow up) than with OP's question.

  • $\begingroup$ Hey @HenrikSchumacher, another question, How can I select a specific item from a nested list, for example, suppose that I have L = {a,{b,c}}, and i want do create s={a,c}, how can I select the c element from L? $\endgroup$ – Herr Schrödinger Sep 12 '18 at 5:07
  • 1
    $\begingroup$ That would be L[[2,2]]: It is the 2nd element in the 2nd sublist. Analogously, you would get b by L[[2,1]] and a by L[[1]]. $\endgroup$ – Henrik Schumacher Sep 12 '18 at 5:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.