For a 10x10 grid, from the center of the grid, the probability of travelling in four directions is 1/4, and if you encounter a boundary (hitting a wall) during the walk, then reject this step. So the resulting distributions are evenly distributed? The result is a uniform distribution. We can use the Metroplis sample to explain. First of all the sampling process to meet the meticulous balance, because we are in the wall when the reject, the implicit Markov transfer matrix is obviously the various state traversal, so the final uniform distribution is not surprising.
% Random_walk bounded 001% 2 dimensional random walk on a 100x100 latticefprintf (' Random walk on a bounded lattice\n ');% l Attice sizelsize = 10;lattice = Zeros (lsize); fprintf (' lattice size =%d\n ', lsize);% number of random walksmaxn = 1000000; fprintf (' number of random walks =%d\n ', MAXN);% start from the centerx0 = Floor (LSIZE/2); y0 = Floor (LSIZE/2); for I=1:MAXN x1 = x0 + Randi (2) *2-3; Y1 = y0 + Randi (2) *2-3; If x1<=0 x1 = 1; End if x1>lsize x1 = lsize; End If y1<=0 y1 = 1; End If y1>lsize y1 = lsize; End Lattice (x1, y1) = Lattice (x1,y1) + 1; x0 = x1; y0 = Y1;endmean_value = mean (reshape (lattice, [lsize*lsize,1])); std_value = STD (reshape (lattice, [lsize*lsize,1])); fprintf (' Mean =%f std =%g\n ', Mean_value, Std_value); fprintf (' Std/mean =%f\n ', std_value/mean_value);
Partial output results
>> Rand_walk_boundedrandom Walk on a bounded latticelattice size = 10Number of random walks = 1000000Mean = 10000.00 0000 std = 117.798std/mean = 0.011780
Clumsy to draw a probability map (ignoring the colorful colors, I do not know how to get down @[email protected]), pay attention to the scale of the z-axis.
Random walking on two-dimensional finite lattice points