0
$\begingroup$

I have this stochastic ODE, where I'm using ParametricNDSolve and WhenEvents :

s = ParametricNDSolve[{V'[t] == 
Piecewise[ {  { (a + mu[t])*V[t], 
   V[t] < V0 }, {(a + mu[t])*V[t]^(2/3)*
     V0^(1/3)*(1 - m[t]/(1 + m[t])) - (b + nu[t])*(V[t] - V0), 
   V0 < V[t]}  }   ], 
WhenEvent[Mod[t, dt] == 0., mu[t] -> RandomReal[{-a, a}]], 
WhenEvent[Mod[t, dt] == 0., nu[t] -> RandomReal[{-b, b}]], 
WhenEvent[Mod[t, dt] == 0., gamma[t] -> RandomReal[{-c, c}]], 
WhenEvent[Mod[t, dt] == 0., delta[t] -> RandomReal[{-d, d}]], 
m'[t] == 
Piecewise[{{0, 
   V[t] < V0}, {(c + gamma[t])*(V[t] - V0) - (d + delta[t])*m[t], 
   V[t] > V0}}], V[0] == Vt0, m[0] == 0, mu[0] == 0, nu[0] == 0, 
gamma[0] == 0, delta[0] == 0}, {V, m, mu, nu, gamma, delta}, {t, 
tmin, tmax}, {a, b, c, d, V0, Vt0}, 
DiscreteVariables -> {mu, nu, gamma, delta}]

Now I would like to solve it many times but not with the same solutions. Meaning if I call twice :

 a = 0.1
 V0 = 1
 Vt0 = 0.5
 b = 0.1
 c = 0.2
 d = 0.3

 Plot[{Evaluate[V[a, b, c, d, V0, Vt0][t] /. s], 
         Evaluate[V[a, b, c, d, V0, Vt0][t] /. s]}, {t, tmin, tmax}]

I get the same two curves, which means that Mathematica took the same list of random numbers for the 2 evaluations. I would like that to change, using for example a random seed and not the same one for the 2 calls, so that the lists of random numbers will not be the same when I'll call my solution twice (when changing the random seed for instance).

Thx

$\endgroup$
  • $\begingroup$ Have you seen ItoProcess? Might be of interest to you. $\endgroup$ – Henrik Schumacher Apr 11 at 10:06
  • $\begingroup$ @J.A What problem do you want to solve? $\endgroup$ – Alex Trounev Apr 11 at 14:24
  • $\begingroup$ @AlexTrounev I'm not sure I got your question $\endgroup$ – J.A Apr 11 at 15:28
  • $\begingroup$ @J.A What problem do you want to solve using this code? $\endgroup$ – Alex Trounev Apr 11 at 15:33

Your Answer

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

Browse other questions tagged or ask your own question.