[Solved]Generating Random Walk Redux 4 Points Random Walk Three Dimensions Along Cubic Grid Equal Q37260634

Generating a Random Walk (Redux) 4 points A random walk in three dimensions along a cubic grid has equal probability of veering off in any direction. Over time, this means that the expected total distance travel increases, but the mean expected position remains the origin (0,0,0) Compose a function random_walk_distance_3d which accepts a number of steps n and an optional argument seed with default of 101. This function should return the distance traveled from the origin after a random walk of n steps of size 1, chosen from the four cardinal directions (in order by bands of probability each: forward, backward, left, right, up, down) Your submission should include a function random_walk_distance_3d n, seed). Note that this is just a random walk: there is no figure-of-merit f to track. Starter code (o iew) Answer* 1 import numpy as np 2 def random_walk distance 3d( n, seed-101) 3 np.random.seed seed) 4 Xyz np.random.uniform( size-(3,)) np.array( ( ) ) # “forward” looking at array in quadrant 4 0,-1, b- np.array( ( 0,+1, 0 ) ) # “back” looking at array in quadrant 4 # fill in here 7 8 9 fori in range : # Take a random step, 25% chance in each direction. chance – np.random.uniform() if chance < 1/6: 10 12 13 14 xyz-xyzf elif chance< 1/3: xyz -xyz b elif #fill in here 16 17 18 x -xyz ] 19 20 return np.sqrt( x*x y”y z*z ) # fill in here Show transcribed image text Generating a Random Walk (Redux) 4 points A random walk in three dimensions along a cubic grid has equal probability of veering off in any direction. Over time, this means that the expected total distance travel increases, but the mean expected position remains the origin (0,0,0) Compose a function random_walk_distance_3d which accepts a number of steps n and an optional argument seed with default of 101. This function should return the distance traveled from the origin after a random walk of n steps of size 1, chosen from the four cardinal directions (in order by bands of probability each: forward, backward, left, right, up, down) Your submission should include a function random_walk_distance_3d n, seed). Note that this is just a random walk: there is no figure-of-merit f to track. Starter code (o iew) Answer* 1 import numpy as np 2 def random_walk distance 3d( n, seed-101) 3 np.random.seed seed) 4 Xyz np.random.uniform( size-(3,)) np.array( ( ) ) # “forward” looking at array in quadrant 4 0,-1, b- np.array( ( 0,+1, 0 ) ) # “back” looking at array in quadrant 4 # fill in here 7 8 9 fori in range : # Take a random step, 25% chance in each direction. chance – np.random.uniform() if chance
Expert Answer
Answer to Generating a Random Walk (Redux) 4 points A random walk in three dimensions along a cubic grid has equal probability of … . . .
OR

