Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Euclidean distance of all pairwise combinations (redundants)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg128672] Re: Euclidean distance of all pairwise combinations (redundants)
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Thu, 15 Nov 2012 03:59:55 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <20121114062906.D261769B8@smc.vnet.net>

Left one off

Outer[EuclideanDistance[##] &, list, list, 1] // Flatten

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


Bob Hanlon


On Wed, Nov 14, 2012 at 12:01 PM, Bob Hanlon <hanlonr357 at gmail.com> wrote:
> You want to use Tuples rather than Subsets
>
> 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}
>
> Norm /@ Subtract @@@ Tuples[list, 2]
>
> {0, Sqrt[2], 2 Sqrt[2], Sqrt[2], 0, Sqrt[2], 2 Sqrt[2], Sqrt[2], 0}
>
> Norm[Subtract[##]] & @@@ Tuples[list, 2]
>
> {0, Sqrt[2], 2 Sqrt[2], Sqrt[2], 0, Sqrt[2], 2 Sqrt[2], Sqrt[2], 0}
>
> Norm[#[[1]] - #[[2]]] & /@ Tuples[list, 2]
>
> {0, Sqrt[2], 2 Sqrt[2], Sqrt[2], 0, Sqrt[2], 2 Sqrt[2], Sqrt[2], 0}
>
> Outer[Norm[#1 - #2] &, list, list, 1] // Flatten
>
> {0, Sqrt[2], 2 Sqrt[2], Sqrt[2], 0, Sqrt[2], 2 Sqrt[2], Sqrt[2], 0}
>
>
> Bob Hanlon
>
>
> On Wed, Nov 14, 2012 at 1:29 AM, Jesse Pisel <jessepisel at 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 b=
etween 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 examp=
le, 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 ret=
ained in the results. I have been using this code just to play with data bu=
t 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 in=
cluding redundants and self references?
>>
>>



  • Prev by Date: Re: Euclidean distance of all pairwise combinations (redundants)
  • Next by Date: The risks of Sphere export
  • Previous by thread: Re: Euclidean distance of all pairwise combinations (redundants)
  • Next by thread: Re: Euclidean distance of all pairwise combinations (redundants)