       random walk

• To: mathgroup at smc.vnet.net
• Subject: [mg132471] random walk
• From: mdc.ferreira at campus.fct.unl.pt
• Date: Mon, 24 Mar 2014 00:20:31 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• Delivered-to: l-mathgroup@wolfram.com
• Delivered-to: mathgroup-outx@smc.vnet.net
• Delivered-to: mathgroup-newsendx@smc.vnet.net

```   RandomWalk[n_, d_] :=
NestList[(# + Table[Random[Real, {-1, 1}], {d}]) &, Table[0, {d}],
n];

ThreeDim = RandomWalk[5000, 3];

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 <= 1000, i++,
walk = RandomWalk[1000, 3];
finalPos = walk[]; EME = 1;
While[True,
finalPos = finalPos + walk[Random[]];
If[Norm[finalPos] > 15, Break[]];
EME = EME + 1;
];
W = Append[W, finalPos];
]
but i want these two codes to be related and my second code takes too much time to run. Would like some help please :)

```

• Prev by Date: Re: Mapping tag-value lists to a third
• Next by Date: Thick surface cordinates along surface normal.
• Previous by thread: Re: Problems with Solve
• Next by thread: Thick surface cordinates along surface normal.