I did these so far:
EDIT---------------
steps=@ (m) 2*randi([0,1],[1,m])-1;
Walk1D =@ (n) [0,cumsum(steps(n))];
findend=@ (x) x(end);
LastPoint1D=@(n) findend(Walk1D(n));
nsteps=200;
nsq=floor(sqrt(nsteps));
MeanSquareDistance1D= @ (n,m) m.*sum((LastPoint1D(n)).^2)./m;
r2D=MeanSquareDistance1D(100,1000)
data=[ ];
for i=10:20:90
data=[data; i , MeanSquareDistance1D(i,2000)]
end
The only problem now,is that the 2nd column of "data" must give me values around
10
30
50
70
90
but not exactly.Only approximately.For example ,the "data" must be:
10 10.184
30 27.51
50 50.306
70 68.394
90 90.414
Sth is wrong with the sum maybe?