Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #12332 > unrolled thread

Euclidean distance of all pairwise combinations (redundants)

Started byJesse Pisel <jessepisel@gmail.com>
First post2012-11-14 06:33 +0000
Last post2013-02-01 06:16 +0000
Articles 7 — 6 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Euclidean distance of all pairwise combinations (redundants) Jesse Pisel <jessepisel@gmail.com> - 2012-11-14 06:33 +0000
    Re: Euclidean distance of all pairwise combinations (redundants) "Nasser M. Abbasi" <nma@12000.org> - 2012-11-15 09:07 +0000
    Re: Euclidean distance of all pairwise combinations (redundants) Ray Koopman <koopman@sfu.ca> - 2012-11-18 09:03 +0000
    Re: Euclidean distance of all pairwise combinations (redundants) vasiliadesmixalis@gmail.com - 2013-02-01 01:46 +0000
      Re: Euclidean distance of all pairwise combinations (redundants) Ray Koopman <koopman@sfu.ca> - 2013-02-01 06:16 +0000
    Re: Euclidean distance of all pairwise combinations (redundants) Francisco Gutierrez <fgutiers2002@yahoo.com> - 2013-02-01 06:15 +0000
    Re: Euclidean distance of all pairwise combinations (redundants) Bob Hanlon <hanlonr357@gmail.com> - 2013-02-01 06:16 +0000

#12332 — Euclidean distance of all pairwise combinations (redundants)

FromJesse Pisel <jessepisel@gmail.com>
Date2012-11-14 06:33 +0000
SubjectEuclidean distance of all pairwise combinations (redundants)
Message-ID<k7ve05$s08$1@smc.vnet.net>
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?

[toc] | [next] | [standalone]


#12351

From"Nasser M. Abbasi" <nma@12000.org>
Date2012-11-15 09:07 +0000
Message-ID<k82bbk$7mn$1@smc.vnet.net>
In reply to#12332
On 11/14/2012 12:33 AM, Jesse Pisel wrote:
>
> 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?
>
>

may be

------------------
list = {{1, 1}, {2, 2}, {3, 3}}
EuclideanDistance @@@ Tuples[list, 2]
-----------------


{0,Sqrt[2],2 Sqrt[2],Sqrt[2],0,Sqrt[2],2 Sqrt[2],Sqrt[2],0}
  
--Nasser

[toc] | [prev] | [next] | [standalone]


#12375

FromRay Koopman <koopman@sfu.ca>
Date2012-11-18 09:03 +0000
Message-ID<k8a88t$89l$1@smc.vnet.net>
In reply to#12332
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]

[toc] | [prev] | [next] | [standalone]


#13326

Fromvasiliadesmixalis@gmail.com
Date2013-02-01 01:46 +0000
Message-ID<kef6p5$k96$1@smc.vnet.net>
In reply to#12332
Hi,

I am wondering on how to get the euclidean distance between all the point from two different list .

For example : list1=[{1,1,1},{1,3,1},{3,2,4}] , list2=[{1,2,1},{1,2,3}] etc.

how to find the euclidean comparing all the pairs ?? {1,1,1} with {1,2,1} and then {1,1,1} with {1,2,3} etc...

[toc] | [prev] | [next] | [standalone]


#13331

FromRay Koopman <koopman@sfu.ca>
Date2013-02-01 06:16 +0000
Message-ID<kefmj5$lj9$1@smc.vnet.net>
In reply to#13326
On Jan 31, 5:46 pm, vasiliadesmixa...@gmail.com wrote:
> Hi,
>
> I am wondering on how to get the euclidean distance between all the point from two different list .
>
> For example : list1=[{1,1,1},{1,3,1},{3,2,4}] , list2=[{1,2,1},{1,2,3}] etc.
>
> how to find the euclidean comparing all the pairs ?? {1,1,1} with {1,2,1} and then {1,1,1} with {1,2,3} etc...

Partition[Norm/@Plus@@Transpose@Tuples@{list1,-list2},Length@list2]

{{1, Sqrt[5]}, {1, Sqrt[5]}, {Sqrt[13], Sqrt[5]}}

[toc] | [prev] | [next] | [standalone]


#13328

FromFrancisco Gutierrez <fgutiers2002@yahoo.com>
Date2013-02-01 06:15 +0000
Message-ID<kefmiv$lj6$1@smc.vnet.net>
In reply to#12332
One way would be with Outer. Simply take care of plugging in the level at which you want the operation performed.lista1={{1,1,1},{1,3,1},{3,2,4}}
lista2={{1,2,1},{1,2,3}}

 Outer[EuclideanDistance,lista1,lista2,1]


Note the 1 at the end, for level 1.



Ouput: {{1,Sqrt[5]},{1,Sqrt[5]},{Sqrt[13],Sqrt[5]}}
Francisco



________________________________

From: "vasiliadesmixalis@gmail.com" <vasiliadesmixalis@gmail.com>
Sent: Thursday, January 31, 2013 8:47 PM
Subject: Re: Euclidean distance of all pairwise combinations (redundants)

Hi,

I am wondering on how to get the euclidean distance between all the point from two different list .

For example : list1=[{1,1,1},{1,3,1},{3,2,4}] , list2=[{1,2,1},{1,2,3}] etc.

how to find the euclidean comparing all the pairs ?? {1,1,1} with {1,2,1} and then {1,1,1} with {1,2,3} etc...

[toc] | [prev] | [next] | [standalone]


#13329

FromBob Hanlon <hanlonr357@gmail.com>
Date2013-02-01 06:16 +0000
Message-ID<kefmjb$ljc$1@smc.vnet.net>
In reply to#12332
It isn't clear what form you want the output to take

list1 = Array[a, {3, 3}];

list2 = Array[b, {2, 3}];

list3 = Outer[Norm[#1 - #2] &, list1, list2, 1]

or

list3 // Flatten


Bob Hanlon


On Thu, Jan 31, 2013 at 8:47 PM,  <vasiliadesmixalis@gmail.com> wrote:
> Hi,
>
> I am wondering on how to get the euclidean distance between all the point from two different list .
>
> For example : list1=[{1,1,1},{1,3,1},{3,2,4}] , list2=[{1,2,1},{1,2,3}] etc.
>
> how to find the euclidean comparing all the pairs ?? {1,1,1} with {1,2,1} and then {1,1,1} with {1,2,3} etc...
>

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web