1
$\begingroup$

Is it possible to speed up SDE simulation in Mathematica? I am simulating a large number of Heston processes that look like the following (note this code is only a slight modification of the documentation here https://reference.wolfram.com/language/example/HestonModel.html):

cW[\[Rho]_] := 
  ItoProcess[{{0, 0}, IdentityMatrix[2]}, {{w1, w2}, {0, 0}}, 
   t, {{1., \[Rho]}, {\[Rho], 1.}}];
hm = ItoProcess[{\[DifferentialD]s[
       t] == \[Mu] s[t] \[DifferentialD]t + 
      Sqrt[r[t]] s[
        t] \[DifferentialD]Subscript[w, s][t], \[DifferentialD]r[
       t] == \[Kappa] (\[Theta] - 
         r[t]) \[DifferentialD]t + \[Xi] Sqrt[
        r[t]] \[DifferentialD]Subscript[w, \[Nu]][t]}, {s[t], 
    r[t]}, {{s, r}, {Subscript[s, 0], Subscript[r, 0]}}, 
   t, {Subscript[w, s], Subscript[w, \[Nu]]} \[Distributed] 
    cW[\[Rho]]];
Subscript[s, 0] = 1.;
Subscript[r, 0] = .10;
{\[Mu], \[Kappa], \[Theta], \[Xi], \[Rho]} = {0, 1.58, .10, .1, -.8};

z = RandomFunction[hm, {0, 30, .5}, 10000, 
   Method -> "EulerMaruyama"] // AbsoluteTiming

enter image description here

I've noticed that MATLAB runs these types of simulations at the very least, four times faster.

$\endgroup$

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.