I defined a security boundary for a random walk:
p = 5000;(*steps*)
tc = 15;(*cube edge length*)
tp = 0.2;
random = Accumulate[
Join[{RandomReal[{-tc, tc}/2, 3]},
RandomVariate[NormalDistribution[0, tp], {p, 3}]]];
periodizedWalk = Mod[random, tc, -tc/2];
splitPeriodizedWalk =
Split[periodizedWalk, EuclideanDistance[#1, #2] < tc/2 &];
With[{cube = First[PolyhedronData["Cube"]]},
Graphics3D[{{Opacity[0.1], Scale[cube, tc]}, Line[random]},
Boxed -> False]]
and now i want to obtain a sample of the random times at which the random walk crosses the boundary for the first time. Something like this:
W = {}; For[i = 1, i <= 5000, i++,
PosFinal = {0, 0}; EME = 1;
While[True,
PosFinal = PosFinal + step[Random[]];
If[Norm[PosFinal] > 15, Break[]];
EME = EME + 1;
];
W = Append[W, EME];
]
but i want these two codes to be related. Would like some help please :)