The formula for computing the distance between two points in the (x, y)
plane is fairly known and straightforward.
However, what is the best way to approach a problem with n
points, for which you want to compute the average distance?
Example:
import matplotlib.pyplot as plt
x=[89.86, 23.0, 9.29, 55.47, 4.5, 59.0, 1.65, 56.2, 18.53, 40.0]
y=[78.65, 28.0, 63.43, 66.47, 68.0, 69.5, 86.26, 84.2, 88.0, 111.0]
plt.scatter(x, y,color='k')
plt.show()
The distance is simply rendered as:
import math
dist=math.sqrt((x2-x1)**2+(y2-y1)**2)
But this is a problem of combinations with repetitions that are not allowed. How to approach it?
O(n^2) > t > O(n)
– Ceyx