# Using “RandomFunction” to simulate a Itoprocess with Random initial condition

I have an itoprocess such as:

ItoProcess[{\[DifferentialD]vx[t] == -vx[t]*\[DifferentialD]t +
2*\[DifferentialD]w[t], \[DifferentialD]x[t] == vx[t]*\[DifferentialD]t},
x[t], {{x, vx}, {x0, 0}}, t, w \[Distributed] WienerProcess[]]


I want to simulate this process 10000 time by using RandomFunction. However, I need the initial value of x (x0) to be Normal distributed such as x0 = RandomVariate[NormalDistribution[0,1]]. But the ItoProcess in Mathematica doesn't support random initial condition.

Is there any method to solve this problem?

• Just add the random initial condition to the whole curve after it was sampled? – Henrik Schumacher May 16 '18 at 18:51
• Thank you for helping! I think it works for random X0, but sometimes I also want the initial velocity vx0 to be random, which may not be applicable. – Shiqi May 17 '18 at 6:25

## 2 Answers

Perhaps something like this would be helpful:

proc := With[{x0 = RandomVariate[NormalDistribution[0, 1]]},
ItoProcess[
{\[DifferentialD]vx[t] == -vx[t]*\[DifferentialD]t + 2*\[DifferentialD]w[t], \[DifferentialD]x[t] ==  vx[t]*\[DifferentialD]t},
x[t], {{x, vx}, {x0, 0}}, t, w \[Distributed] WienerProcess[]]
]


then

With[{n = 350},
TemporalData[Nest[Join[#, {RandomFunction[proc, {0, 29, 1}]}] &, {}, n]] // ListLinePlot
] • Thanks a lot for helping! Yesterday I also try to solve this by using the "Table" such as "TemporalData[Table[Randomfunction[ItoProcess[...{{x, vx}, {RandomVariate[NormalDistribution[0,1]], 0}}, t, ...],{0,3,0.001}],10000]]". I will try if the two method are both applicable! – Shiqi May 17 '18 at 6:31
• You are welcome! I haven't tried what you are suggesting but it seems plausible that it would work in principle. Please note that the amount of data points you are generating is substantial and I have doubts whether either approach will be practical when time/memory considerations are taken into account (on an old machine the estimated time to make 10000 repetitions with the specified step is approx. 15 mins and 257MB in size); perhaps you should consider the suggestions in the comments and/or the other answers as viable alternatives for the volume of your data requirements – user42582 May 17 '18 at 6:48

I think this is essentially what @HenrikSchumacher suggested:

nsim = 10;
ito = RandomFunction[ItoProcess[{\[DifferentialD]vx[t] == -vx[t]*\[DifferentialD]t +
2*\[DifferentialD]w[t], \[DifferentialD]x[t] == vx[t]*\[DifferentialD]t},
x[t], {{x, vx}, {x0, 0}}, t, w \[Distributed] WienerProcess[]], {0., 5., 0.01}]
ListLinePlot[ito /. x0 -> #] & /@RandomVariate[NormalDistribution[0, 1], nsim] Mean[ito /. x0 -> #] & /@RandomVariate[NormalDistribution[0, 1], nsim]
(* {0.264367, 0.555122, -1.45459, 0.663994, -3.19353, -0.383676, 0.51233, -1.1766,
1.54617, 1.6006} *)

• Thanks a lot for helping! In my problem I need to derive the distribution of X at some fixed time. So I also have to use orders such as "["SliceData",t]". I will try if I can define the 10000 trajectories as a TemporalData by using your method. Thanks again! – Shiqi May 17 '18 at 6:37