1
$\begingroup$

I define the following 6 dimensional stochastic (Ito) process- in velocity v/position x. I can plot x1 as a function of t- see script below which has been corrected by Daniel. My goal is however to plot the path [x1[t],x2[t],x3[t]] in 3D. Any help?

$\endgroup$
2
  • 1
    $\begingroup$ There are syntax errors in your code, e.g. [DifferentialD] should be replaced by d and [Distributed] should be replaced by \[Distributed]. $\endgroup$
    – user64494
    Nov 12 '21 at 7:34
  • $\begingroup$ corrected below $\endgroup$ Nov 12 '21 at 18:04
1
$\begingroup$

You can change the Ito process to output the three x values, {x1[t],x2[t],x3[t]} instead of just x1[t]:

proc = ItoProcess[{\[DifferentialD]x1[t] == 
v1[t] \[DifferentialD]t, \[DifferentialD]x2[t] == 
v2[t] \[DifferentialD]t, \[DifferentialD]x3[t] == 
v3[t] \[DifferentialD]t, \[DifferentialD]v1[t] == -0.1*
  v1[t] \[DifferentialD]t + \[DifferentialD]n1[
   t], \[DifferentialD]v2[t] == -0.1*
  v2[t] \[DifferentialD]t + \[DifferentialD]n2[
   t], \[DifferentialD]v3[t] == -0.1*
  v3[t] \[DifferentialD]t + \[DifferentialD]n3[t]}, 
{x1[t], x2[t],x3[t]}, 
{{x1, x2, x3, v1, v2, v3}, {0, 0, 0, 0, 0, 0}}, 
t, {n1 \[Distributed] WienerProcess[], 
    n2 \[Distributed] WienerProcess[], 
    n3 \[Distributed] WienerProcess[]}]

After solving this version of the Ito process, extract and plot the paths:

Graphics3D[Line[sol["ValueList"]]]

If you want to style each path, you can extract them individually from the solution, e.g, with sol["Values",p] for the {x1,x2,x3} values for path p.

paths from Ito stochastic process

$\endgroup$
2
  • $\begingroup$ Thank Tad. That is starting to help. Is there a way to have each sample path in different color? I need these (or variations around the same problem) for an article I am preparing for The Astrophysical Journal. $\endgroup$ Nov 12 '21 at 19:33
  • $\begingroup$ @NicolasBian For different colors Table[sol["Values", i], {i, 1, 50}] // ListPointPlot3D[#, AspectRatio -> 1] & $\endgroup$ Nov 12 '21 at 22:36
1
$\begingroup$

I corrected Differential and Distributed:

proc = ItoProcess[{\[DifferentialD]x1[t] == 
    v1[t] \[DifferentialD]t, \[DifferentialD]x2[t] == 
    v2[t] \[DifferentialD]t, \[DifferentialD]x3[t] == 
    v3[t] \[DifferentialD]t, \[DifferentialD]v1[t] == -0.1*
      v1[t] \[DifferentialD]t + \[DifferentialD]n1[
       t], \[DifferentialD]v2[t] == -0.1*
      v2[t] \[DifferentialD]t + \[DifferentialD]n2[
       t], \[DifferentialD]v3[t] == -0.1*
      v3[t] \[DifferentialD]t + \[DifferentialD]n3[t]}, 
  x1[t], {{x1, x2, x3, v1, v2, v3}, {0, 0, 0, 0, 0, 0}}, 
  t, {n1 \[Distributed] WienerProcess[], 
   n2 \[Distributed] WienerProcess[], 
   n3 \[Distributed] WienerProcess[]}] 
sol = RandomFunction[proc, {0., 100, 0.1}, 50, 
  Method -> "StochasticRungeKutta"]; ListLinePlot[sol]

enter image description here

Addendum

If you want to plot the 3 first data-path as 3D path you may do this by:

ListLinePlot3D[sol["Values", 1 ;; 3] // Transpose]

enter image description here

$\endgroup$
6
  • $\begingroup$ Thank you Daniel. I would like to plot (x1,x2,x3) as a function of time in 3D? any clue? $\endgroup$ Nov 12 '21 at 17:57
  • $\begingroup$ Think of ListPointPlot3D. $\endgroup$
    – user64494
    Nov 12 '21 at 18:08
  • $\begingroup$ Can you give me a script that would do? thanks $\endgroup$ Nov 12 '21 at 18:13
  • $\begingroup$ I am not sure if I understand you correctly. I added a 3D path out of the first 3 paths from "sol" to my answer $\endgroup$ Nov 12 '21 at 20:31
  • $\begingroup$ Thanks Daniel. I have 1 path of x1,x2,x3 as function of time. That's the meaning of 1;;3 I guess. 4;;6 would give the velocity path. So what is the meaning of transpose? what if I want 30 paths? $\endgroup$ Nov 13 '21 at 14:18

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.