TransWikia.com

Extracting solutions from SDE

Mathematica Asked by rami_salazar on March 14, 2021

I have an SDE system which I solve using

proc = ItoProcess[{[DifferentialD]kai1[z] == 
    0.0001*I*kai1[z] [DifferentialD]w1[z] + 
     I*kai1 [z] [DifferentialD]w2[z] - 
     I*kai3[z] [DifferentialD]w3[z] + kai3[z] [DifferentialD]w4[z] +
      kai1[z] [DifferentialD]z,
   [DifferentialD]kai2[z] == 
    I*kai2[z] [DifferentialD]w1[z] + .1*I*
      kai2[z] [DifferentialD]w2[z] - 
     I*kai4[z] [DifferentialD]w3[z] + kai4[z] [DifferentialD]w4[z] +
      kai2[z] [DifferentialD]z,
   [DifferentialD]kai3[z] == 
    I*kai1[z] [DifferentialD]w1[z] - 
     I*kai3[z] [DifferentialD]w2[z] + 
     I*kai1[z] [DifferentialD]w3[z] + kai1[z] [DifferentialD]w4[z] +
      kai3[z] [DifferentialD]z,
   [DifferentialD]kai4[z] == 
    I*kai4[z] [DifferentialD]w1[z] + 
     I*kai1[z] [DifferentialD]w2[z] - 
     I*kai3[z] [DifferentialD]w3[z] + kai3[z] [DifferentialD]w4[z] +
      kai1[z] [DifferentialD]z}, {kai1[z], kai2[z], kai3[z], 
   kai4[z]}, {{kai1, kai2, kai3, kai4}, {1, 0, 0, 1}}, 
  z, {w1 [Distributed] WienerProcess[], 
   w2 [Distributed] WienerProcess[], 
   w3 [Distributed] WienerProcess[], 
   w4 [Distributed] WienerProcess[]}]

and then

sol = RandomFunction[proc, {0, 1, 0.01}]

I can then plot the solution via

ListLinePlot[Abs[sol]^2 , PlotRange -> All]

But how can I extract just one of the solutions, ie kai1,2,3,4?

Thanks

2 Answers

Given sol from your code, I'd do it like this:

data = sol["Path"];
munger[{x_, y_}] := {x, Abs[#]^2} & /@ y
{path1, path2, path3, path4} = Transpose[munger /@ data];
ListLinePlot[{path1, path2, path3, path4}, PlotLegends -> {kai1, kai2, kai3, kai4}]

plot

Correct answer by m_goldberg on March 14, 2021

sol is TemporalData so you can extract the data from it

abs = Abs[sol]^2;
data = abs["Paths"][[1, 2 ;;]];
split = Table[{#[[1]], #[[2, i]]} & /@ data, {i, 1, 4}];

split has 4 elements corresponding to the x, y values for each function.

ListLinePlot /@ split // GraphicsRow

enter image description here

Answered by Rohit Namjoshi on March 14, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP