3
$\begingroup$

I was wondering if its possible to draw the simulated paths of an Ito diffusion over the probability density function.

Ito Process:

proc[μ_, σ_] := ItoProcess[\[DifferentialD]x[t] == μ \[DifferentialD]t
  + σ \[DifferentialD]w[t], x[t], {x, 0}, t, w \[Distributed] WienerProcess[]]

paths = RandomFunction[proc[0.5, 1], {0, 10, 0.01}, 100]

plot = ListLinePlot[paths, AxesLabel -> {t, x}, 
  PlotStyle -> Directive[Opacity[0.25], Thin], 
  PlotLabel -> Style[" μ=0.5, σ=1 ", Bold], 
  PlotRange -> All, ImageSize -> 450]

enter image description here

And the transition probability function or Forward Kolmogorov is the following

Plot3D[E^(-((-x + x0 + t μ)^2/(2 t σ^2)))/(Sqrt[2 π] Sqrt[t σ^2])
  /. {μ -> 0.5, σ -> 1, x0 -> 0}, {t, 0, 5}, {x, -5, 5}, AxesLabel -> Automatic]

enter image description here

So, again my question is if it is possible to display the simulated paths over the canvas of the probability density function. It would be a very nice visual aid.

Thank you in advance!

$\endgroup$
6
$\begingroup$

Using the code as in the OP, slightly modified:

proc[μ_, σ_] := 
  ItoProcess[
    \[DifferentialD]x[t] == μ \[DifferentialD]t + σ \[DifferentialD]w[t],
    x[t], {x, 0}, t,
    w \[Distributed] WienerProcess[]
  ]
paths = RandomFunction[proc[0.5, 1], {0, 10, 0.01}, 100];

Then, we define the function

f[x_, t_] = E^(-((-x + x0 + t μ)^2/(2 t σ^2)))/(Sqrt[2 π] Sqrt[t σ^2]) /. {μ -> 0.5, σ -> 1, x0 -> 0};

and construct sets of points tracing out the trajectories in 3D using

lsts = DeleteCases[
  Table[{#1, #2, f[#2, #1]} & @@@ paths["Path", k], {k, 1, 20}],
    {__, Indeterminate}, Infinity]

Finally, plot the function:

p1 = Plot3D[f[x, t],
      {t, 0, 5}, {x, -5, 5},
      AxesLabel -> Automatic, PlotStyle -> Opacity[0.3],
      Mesh -> None, BoundaryStyle -> None];

and show this with the lines constructed from the sets of points:

Show[p1, Graphics3D[Line /@ lsts]]

enter image description here

enter image description here

To get different colors, you could do something like

Module[{i = 1},
  Show[p1, Graphics3D[{Opacity[0.25], {Hue[i++/Length@lsts], Line@#} & /@ lsts}]]
 ]

enter image description here

Play with it!

$\endgroup$
  • $\begingroup$ Thank you so much. That looks awesome. Is there a chance you could write the tracing with regular notation. For me its a little hard to read with the Wolfram notation @@@ $\endgroup$ – Edv Beq Jul 7 '16 at 23:19

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.