I was looking for help writing this code for a program that simulates a random walk of 25 steps.
The (person) can either walk East or West.
The program has to compute and output to the screen the following:
The average distance from the starting point at the end of the 25 steps. The average number of times that the random walk returned to the starting point during the 25 steps.
Also it simulates a random walk of increments: 1 step, then 2 steps, then 3 steps, then 4 steps, ..., up to 50 steps.
Note: 1 = east and 2 = west
This is what I have so far, any suggestions would be greatly appreciated.
import random
x = 0
y = 0
def randomWalk(N):
for i in range (1, (N)):
a = random.randint
if a == 1:
x = x+1
y = y+0
return (x, y)
print (x, y)
if a == 2:
x = x+0
y = y-1
return (x, y)
print (x, y)