This is much easier to do if you build up the program functionally. You have a simple function at the core of the problem: it deserves its own name.
newV[v_] :=
If[RandomReal[] < th, v + f \[Delta]t,
RandomVariate[NormalDistribution[0, Sqrt[T]], {2}]]
Note that defining with :=
means the whole function will be reevaluated each time it is invoked, so you'll get new random numbers. Try it:
newV[{0, 0}]
(* {0.2, 0.} *)
It's easy to repeatedly feed a function's output back into its input in Mathematica. Here, since you want a list of the results, use NestList
:
vrun[] := NestList[newV, {0, 0}, 7]
Try that:
vrun[]
(* {{0, 0}, {0.2, 0.}, {0.4, 0.}, {0.6, 0.}, {0.8, 0.}, {1., 0.}, {45.5901, 4.74823}, {45.7901, 4.74823}} *)
To add up a list, use Total
. Here's what you get for the test above:
Total[%]
(* {94.3802, 9.49646} *)
You want the totals from 2000 runs. I'll give you ten here:
Table[Total[vrun[]], {10}]
(* {{-12.1303, -196.93}, {5.6, 0.}, {-15.5244,
18.5211}, {-32.818, -71.7292}, {-28.6207,
10.4847}, {-39.1328, -52.8502}, {20.7677, 28.3427}, {5.6,
0.}, {-79.5229, 57.5149}, {-79.6053, -52.024}} *)
Unlike procedural programming languages, Mathematica makes it easy to build up computations from simple functions. Simple function are much easier to construct and test than complicated loops.