In an infinite cubic lattice with points separated in x, y and z axis by one unit, a random walk starts from (0, 0, 0). Any of the 6 possible directions is equally likely at each step.
What is the probability of a return to the origin after 2*N moves?
Run all the possibilities through 8 moves. Only even number of moves can result in a return to the origin.
clearvars
global move psn hits tot
move=[0 0 1; 0 1 0; 1 0 0; 0 0 -1; 0 -1 0; -1 0 0];
hits=zeros(1,10); tot=zeros(1,10);
psn=[0 0 0]; accum = 0;
addon(1)
for i=2:2:8
accum = accum+hits(i)/tot(i);
fprintf('%2d %6d %7d %15.13f %15.13f\n',i,hits(i),tot(i),hits(i)/tot(i),accum);
end
function addon(wh)
global move psn hits tot
for dir=1:6
savepsn=psn;
psn=psn+move(dir,:);
if mod(wh,2)==0
tot(wh)=tot(wh)+1;
if isequal(psn,[0,0,0])
hits(wh)=hits(wh)+1;
end
end
if wh<8
addon(wh+1);
end
psn=savepsn;
end
end
cumulative
2*n numerator denominator probability probability
2 6 36 0.1666666666667 0.1666666666667
4 90 1296 0.0694444444444 0.2361111111111
6 1860 46656 0.0398662551440 0.2759773662551
8 44730 1679616 0.0266310871056 0.3026084533608
The numerators are in A002896 in the OEIS and denominators 6^(2*n).
|
Posted by Charlie
on 2024-07-04 07:31:17 |