26 lines
546 B
Matlab
26 lines
546 B
Matlab
p = 0.5;
|
|
nsteps = 100;
|
|
nwalks = 1000;
|
|
|
|
y = zeros( nwalks, nsteps/10 );
|
|
for k = 1:length( y )
|
|
x = randomwalk( nsteps, p );
|
|
for j = 1:nsteps/10
|
|
y(k,j) = x((j-1)*10+1);
|
|
end
|
|
%plot( x )
|
|
%pause( 1 )
|
|
if rem(k,100) == 0
|
|
%[h1,b1] = hist( y(1:k,1), [-50:2:50] );
|
|
%[h2,b2] = hist( y(1:k,2), [-50:2:50] );
|
|
%bar( b1, h1, 1.0, 'b' );
|
|
%hold on;
|
|
%bar( b2, h2, 'FaceColor', 'r' );
|
|
%hold off;
|
|
sdev = var( y(1:k,:), 1 );
|
|
plot( sdev )
|
|
pause( 1.0 );
|
|
end
|
|
end
|
|
|