Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: Euclidean distance of all pairwise combinations (redundants)
Replies: 7   Last Post: Feb 1, 2013 1:16 AM

 Messages: [ Previous | Next ]
 Ray Koopman Posts: 3,383 Registered: 12/7/04
Re: Euclidean distance of all pairwise combinations (redundants)
Posted: Nov 18, 2012 4:03 AM

On Nov 13, 10:35 pm, Jesse Pisel <jessepi...@gmail.com> wrote:
> I have been having a tough time trying to figure out how to include all red undant pairwise combinations in my results for the euclidean distance between a set of points. I have a set of points with xy coordinates and want the euclidean distance between each point including the point and itself. So if my points in xy space are list = {{1, 1}, {2, 2}, {3, 3}} for example, I want the distance from {1, 1} to {1, 1}, {1, 1} to {2, 2}, and {2, 2} to {3, 3} etc. for each point for a total of 9 distances all together. The EuclideanDistance function removes the redundant distances that I want retained in the results. I have been using this code just to play with data but would like to be able to expand up to 500+ points:
>
> list = {{1, 1}, {2, 2}, {3, 3}}
> EuclideanDistance @@@ Subsets[list, {2}]
>
> Any ideas on how to get the euclidean distance between all the points including redundants and self references?

If your lists are long then it will be faster to use

Needs["HierarchicalClustering`"]

Flatten@DistanceMatrix[list, DistanceFunction -> EuclideanDistance]

Date Subject Author
11/14/12 Jesse Pisel
11/15/12 Nasser Abbasi
11/18/12 Ray Koopman
2/1/13 Francisco Gutierrez
2/1/13 Ray Koopman
2/1/13 Bob Hanlon