About a week ago I asked for some help in generating bivariate Ito processes where the components can be correlated (See thread Simulating a bivariate Ito process).b.gates.you.know.what kindly supplied me with a nice solution using the ItoProcess function.
While that addresses my needs in terms of simulations, I thought that it would be interesting to plot the bivariate process as a function of time in $R^2. $ Think of it as plotting a bivariate Brownian motion by changing the level of correlation, which is what the code I supplied does.
If I simulate the data, and then plot them using ListLinePlot[], I get two time plots, one for each component. Instead, it would be nice to see the dynamic of this process as a function of time in $R^2 $ as opposed to two plots in $R^1. $ I was able to do that using the following commands (I am providing the full code that I used, but my question is at the end).
proc[x10_, x20_, \[Sigma]1_, \[Sigma]2_, \[Rho]_] :=
ItoProcess[{\[DifferentialD]x1[t] == 0 \[DifferentialD]t +
\[Sigma]1 \[DifferentialD]Wa[t],
\[DifferentialD]x2[t] == 0 \[DifferentialD]t +
\[Sigma]2 (\[Rho] \[DifferentialD]Wa[t] +
Sqrt[1 - \[Rho]^2] \[DifferentialD]Wb[t])}, {x1[t],
x2[t]}, {{x1, x2}, {x10, x20}}, {t,
0}, {Wa \[Distributed] WienerProcess[],
Wb \[Distributed] WienerProcess[]}]
n = 1000; (* number of points for each unit interval *)
sample = RandomFunction[proc[0,0,1,1,0.9], {0, 5, 1/n},
Method -> "StochasticRungeKutta"];
x = Table[0, n];
y = Table[0, n];
Do[x[[i]] = sample["Paths"][[1, i, 2, 1]], {i, 1, n}];
Do[y[[i]] = sample["Paths"][[1, i, 2, 2]], {i, 1, n}];
bivlist = Thread[{x, y}];
ListPlot[bivlist, Joined -> True]
My question is: is there a better/more efficient way to obtain a plot of one component vs. the other without having to create a new list of values? What I did works fine and it is actually reasonably fast as well, but I am not considering this to be very elegant. Since Mathematica is an elegant tool, I suspect that there must be a better way to achieve what I would like to do. It could very well be that I do not know how to deal with TemporalData very well, unfortunately.
Thank you.
ListLinePlot[sample["Paths"][[1, All, 2]]]
- or even further down to:ListLinePlot[sample["Values"]]
$\endgroup$ – flinty Jul 12 '20 at 17:41