Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started