Skip to content

Instantly share code, notes, and snippets.

@davidagold
Created September 25, 2015 04:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidagold/54bdd8a35e6e619c5a3b to your computer and use it in GitHub Desktop.
Save davidagold/54bdd8a35e6e619c5a3b to your computer and use it in GitHub Desktop.
average pairwise distance over array of Float 2-tuples
function pwise_meandist(A::Array{Tuple{FLoat64, Float64}})
s = 0.0
i = 1
n = length(A)
while i < n
(x0, y0) = A[i]
for j in (i+1):length(A)
(x1, y1) = A[j]
s += sqrt((x0 - x1)^2 + (y0 - y1)^2)
end
i += 1
end
return s/n
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment