Menu

[Solved]T Part B Numpy Computation Exercise Based Python File Distancery Suggest Download File Dis Q37252115

t Part B: numpy computation This exercise is based on the Python file distance.Ry. We suggest that you download the file distExercise on numpy vectorisation import numpy as np pos np.array([[ 1.72, 2.56], [ 0.24, 5.67], [ 1.24, 5.45], [ 3.17, 0.23],thesceond photo is the file distance.pyt Part B: numpy computation This exercise is based on the Python file distance.Ry. We suggest that you download the file distance-py and open it in Spyder because it will make it easier for you to follow the description below The Python file distance.gy defines two numpy arrays with the name pos and ref. The array pos has a shape of (6.2). You can consider each row of pos is used to store the position of an object. For example, post0,0) and post0.1] store, respectively, the x and y-coordinates of the first object The array elements ref0) and reft 1] store, respectively, the x and y-coordinates of a reference point. Your task is to compute the distance between each of the 6 objects in pos from the reference point. If the co-ordinates of the object is (oy) and those of the reference point are (a.b), then their distance is given by the formula: T-a We require that you complete this task using numpy functions and arithmetic operators. You are not all expected answers in the file distance.py allowed to use any loops. You can also find the mpy mathematical functions (link to.numoy man Hints:. You will need to use numpy broadcasting discussed in Week 8’s lecture and some n Exercise on numpy vectorisation import numpy as np pos np.array([[ 1.72, 2.56], [ 0.24, 5.67], [ 1.24, 5.45], [ 3.17, 0.23], 1.12, 1.08]]) ref np.array ([1.22, 1.18]) # The expected answer is an array with 6 elements. # The elements are approximately: # [ 1.468, 4.596, 4.928, 4.611, 2.410, 0.141] # Insert your solution below Show transcribed image text t Part B: numpy computation This exercise is based on the Python file distance.Ry. We suggest that you download the file distance-py and open it in Spyder because it will make it easier for you to follow the description below The Python file distance.gy defines two numpy arrays with the name pos and ref. The array pos has a shape of (6.2). You can consider each row of pos is used to store the position of an object. For example, post0,0) and post0.1] store, respectively, the x and y-coordinates of the first object The array elements ref0) and reft 1] store, respectively, the x and y-coordinates of a reference point. Your task is to compute the distance between each of the 6 objects in pos from the reference point. If the co-ordinates of the object is (oy) and those of the reference point are (a.b), then their distance is given by the formula: T-a We require that you complete this task using numpy functions and arithmetic operators. You are not all expected answers in the file distance.py allowed to use any loops. You can also find the mpy mathematical functions (link to.numoy man Hints:. You will need to use numpy broadcasting discussed in Week 8’s lecture and some n
Exercise on numpy vectorisation import numpy as np pos np.array([[ 1.72, 2.56], [ 0.24, 5.67], [ 1.24, 5.45], [ 3.17, 0.23], 1.12, 1.08]]) ref np.array ([1.22, 1.18]) # The expected answer is an array with 6 elements. # The elements are approximately: # [ 1.468, 4.596, 4.928, 4.611, 2.410, 0.141] # Insert your solution below

Expert Answer


Answer to t Part B: numpy computation This exercise is based on the Python file distance.Ry. We suggest that you download the file… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *