# Non-reversal Random walk (NRRW) Non-reversal random walk are randomly walk except it cannot reverse it's previous step. Following two figures show different steps of NRRW, compare to previous figure it can walk further since it cannot go reverse its previous step. ![](https://i.imgur.com/vcBJkCZ.png) ![](https://i.imgur.com/N6HB1wj.jpg) Then I measure the probability $P(R)$ as a function of $R$ after large enough steps. Different from reversal RW, the peak of probability is not happened at the origin. By taking plot semi-log we see that it doesn't look quite like a Gaussian distribution. We can verified this again by looking at the QQ plot which indicate a Gaussian only if it lay around the $45^\circ$ line. ![](https://i.imgur.com/glwI4xr.png) ![](https://i.imgur.com/aQEBf7N.png) ![](https://i.imgur.com/8ncIFIL.png) ![](https://i.imgur.com/1FSKumc.png) Then I measure $<|R|>$ and $<R^2>$, in particular $<R^2>$ are roughly $\sim$ $N^1$ at large $N$. ![](https://i.imgur.com/BA4rHJV.png) ![](https://i.imgur.com/1hoqMSO.png) ## Code ```fortran= program rw2 implicit none integer, parameter :: N=5000, NP=100000 integer :: x(NP)=0, y(NP)=0, pre(NP), i, j double precision :: p=0.25d0, pp, xa, xb, R call random_seed() open(66, file='gauR.dat', status='unknown') do i = 1, N xa = 0.d0 xb = 0.d0 do j = 1, NP ! non-reversal do call random_number(pp) ! p is the prob. of right if ((pp.lt.p).and.(pre(j).ne.1)) then x(j) = x(j) + 1 pre(j) = 1 else if ((pp.gt.p).and.(pp.le.2.d0*p).and.(pre(j).ne.2)) then x(j) = x(j) - 1 pre(j) = 2 else if ((pp.gt.2.d0*p).and.(pp.le.3.d0*p).and.(pre(j).ne.3)) then y(j) = y(j) + 1 pre(j) = 3 else if ((pp.gt.3.d0*p).and.(pre(j).ne.4)) then y(j) = y(j) - 1 pre(j) = 4 else cycle end if exit end do R = dsqrt(dble(x(j))*dble(x(j))+dble(y(j))*dble(y(j))) xa = xa + R xb = xb + R * R end do ! traj ! write(66, '(2I8)') x(1), y(1) ! <x> xa = xa / dble(NP) ! <x^2> xb = xb / dble(NP) ! write(66, '(I6, 2f25.17)') i, xa, xb end do ! distribution ! write(66, '(100000I8)') x ! write(66, '(100000I8)') y write(66, '(100000f25.17)') dsqrt(dble(x)*dble(x) + dble(y)*dble(y)) end program rw2 ```