title: Python: average distance between a bunch of points in the (x,y) plane
body: <p>The formula for computing the distance between two points in the <code>(x, y)</code> plane is <a href="https://stackoverflow.com/questions/5228383/how-do-i-find-the-distance-between-two-points">fairly known and straightforward</a>.</p>
  
  <p>However, what is the best way to approach a problem with <code>n</code> points, for which you want to compute the average distance?</p>
  
  <p>Example:</p>
  
  <pre><code>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()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/J9bHc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/J9bHc.png" alt="enter image description here"></a></p>
  
  <p>The distance is simply rendered as:</p>
  
  <pre><code>import math
  dist=math.sqrt((x2-x1)**2+(y2-y1)**2)
  </code></pre>
  
  <p>But this is a problem of combinations with repetitions that are not allowed. How to approach it?</p>