I am trying to perform a two-dimensional random walk for a particle, but I am not getting the desired result. The plot produced is a linear plot, which obviously should not have been. Similar code for a one-dimensional gives the desired result. Can someone please suggest where am I making any mistakes? Thanks.
import numpy
import random
HEAD = 1
TAIL = 2
a = numpy.zeros((2, 50))
b = a.transpose()
ns = 50 # no of steps
for step in range(ns):
for _ in range(ns):
coin = random.randint(1,2)
if coin == HEAD:
b[step,0]+=1 # one unit length to the right
elif coin == TAIL:
b[step,1]-=1 # one unit length to the left