[Solved]Generating Random Walk Redux 4 Points Random Walk Three Dimenslons Along Cubic Grid Equal Q37259724
Generating a Random Walk (Redux) 4 points A random walk in three dimenslons 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 tunction randent wa tk 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. steps of slze 1, chosen from the four cardinal directions (in order by bands of K 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 (click to view) Answer 1 import numpy as np 2 def random walk_distance 3d( n,seed 101) 3 p.random.seed( seed) xyz np.random.uniform size-(3,) ” np.array( ( О,-1, 0 ) ) # .forward- looking at array in quadrant 4 b-np.array ( ( О,+1, O ) ) # .back” looking at array in quadrant 4 # fill in here 9 for i in ranget # Take a random step, 25% chance in each direction chance np.random.uniform() if chance < 1/6 n) 10 12 13 xyx xyz+ xys – xyzb elif chance < 1/3: 16 elif #fill in here 181 13 20 x”xyz[ 0 ] fill in here return np. agrtxyy Press F9 to toggle ful-screen mode. Set aditor mode in uner profie AEANSWER ER FOR FEED Show transcribed image text Generating a Random Walk (Redux) 4 points A random walk in three dimenslons 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 tunction randent wa tk 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. steps of slze 1, chosen from the four cardinal directions (in order by bands of K 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 (click to view) Answer 1 import numpy as np 2 def random walk_distance 3d( n,seed 101) 3 p.random.seed( seed) xyz np.random.uniform size-(3,) ” np.array( ( О,-1, 0 ) ) # .forward- looking at array in quadrant 4 b-np.array ( ( О,+1, O ) ) # .back” looking at array in quadrant 4 # fill in here 9 for i in ranget # 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 dimenslons along a cubic grid has equal probability of … . . .
OR

