Question: 4. Numpy drones We are going to start with the same array we did way up above: But this time, instead of Uber drivers, think

 4. Numpy drones We are going to start with the same

4. Numpy drones We are going to start with the same array we did way up above: But this time, instead of Uber drivers, think of these as positions of Alphabet's Wing delivery drones. Now we would like to find the closest drone to a customer who is at 7,1 . With the previous example we used Manhattan Distance. With drones, we can compute the distance as the crow flies -- or Euclidean Distance. We probably learned how to do this way back in 7 th grade when we learned the Pythagorean Theorem which states: c2=a2+b2 Where c is the hypotenuse and a and b are the two other sides. So, if we want to find c : c=a2+b2 If we want to find the distance between the drone and a customer, x and y in the formula becomes Distxy=(x1y1)2+(x2y2)2 and for wing_1a who is at [4,5] and our customer who is at [7,1] then the formula becomes: Distxy=(x1y1)2+(x2y2)2=(47)2+(51)2=32+42=9+16=25=5 Sweet! And to generalize this distance formula: Distxy=(x1y1)2+(x2y2)2 to n-dimensions: Distxy=i=1n(xiyi)2 Can you write a function euclidean that takes 3 arguments: droneLocation, droneNames, and an array representing one customer's position and returns the name of the closest drone

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!