I have to make simulation of a random walk that gets smaller and smaller. Each step the x-axis gets rescaled 1/2 and y-axis by 1/Sqrt[2]
. So one needs more and more steps to get to the end.
So one should get:
n = 0: {{0, 0}},
n = 1: {{0, 0}, {1, 1}}
n = 2: {{0, 0}, {1/2, 1/Sqrt[2]}, {1, 2/Sqrt[2]}}
n = 3: {{0, 0}, {1/4, 1/2}, {1/2, 1)}, {3/4, 1/2}, {1, 1}}
(at n = 4
, one would need 9 steps etc.)
However, I had a problem with defining what the next step should be. My code (now it works) :
randomWalk1000[x_] :=
For[n = 0, n < x, n++,
If [n == 0, path := {{0, 0}}];
If[n == 1, path := {{0, 0}, {1, 1}}, stepsize = 1;];
If[n > 1,
path = Transpose[{path[[All, 1]]/2, path[[All, 2]]/Sqrt[2]}];
For[i = 1, i <= 2^(n - 2), i++,
step = RandomChoice[{-1, 1}];
stepsize /= Sqrt[2];
path1 := Last[path];
AppendTo[
path, { 1/2 + (i/2^(n - 2))*1/2 , path1[[2]] + stepsize*step}]]];
Print[path]]