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


Groups > comp.lang.python > #98028

Re: Nearest neighbours of points

From Terry Reedy <tjreedy@udel.edu>
Newsgroups comp.lang.python
Subject Re: Nearest neighbours of points
Date 2015-10-31 23:00 -0400
Message-ID <mailman.6.1446346873.4463.python-list@python.org> (permalink)
References <81947104-f6dd-48b3-ba7b-f03b0c5b6f39@googlegroups.com> <d9kq38Ft8k9U1@mid.individual.net>

Show all headers | View raw


On 10/31/2015 5:28 PM, Tom P wrote:
> On 10/24/2015 10:05 PM, Poul Riis wrote:
>> I have N points in 3D, organized in a list. I want to to point out the
>> numbers of the two that have the smallest distance.
>> With scipy.spatial.distance.pdist I can make a list of all the
>> distances, and I can point out the number of the minimum value of that
>> list (see simple example below

distances is conceptually a 2-d matrix, but since it would be 
symmetrical, I gather that it is stored as 1-d represention  You should 
be able to find the formula that converts the linear index to the 
indexes of the corresponding symmetric matrix.  It depends on whether 
distances represent the upper or lower triangle of the symmetric matrix 
and whether the triangular matrix is stored by rows or columns.

-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Nearest neighbours of points Poul Riis <priisdk@gmail.com> - 2015-10-24 13:05 -0700
  Re: Nearest neighbours of points Christian Gollwitzer <auriocus@gmx.de> - 2015-10-24 22:45 +0200
  Re: Nearest neighbours of points Poul Riis <priisdk@gmail.com> - 2015-10-24 15:44 -0700
    Re: Nearest neighbours of points Christian Gollwitzer <auriocus@gmx.de> - 2015-10-25 09:55 +0100
      Re: Nearest neighbours of points Poul Riis <priisdk@gmail.com> - 2015-10-25 05:00 -0700
      Re: Nearest neighbours of points Peter Pearson <pkpearson@nowhere.invalid> - 2015-10-25 17:01 +0000
    Re: Nearest neighbours of points Bartc <bc@freeuk.com> - 2015-10-25 12:36 +0000
  Re: Nearest neighbours of points Fabien <fabien.maussion@gmail.com> - 2015-10-26 03:25 +0100
  Re: Nearest neighbours of points Tom P <werotizy@freent.dd> - 2015-10-31 22:28 +0100
    Re: Nearest neighbours of points Terry Reedy <tjreedy@udel.edu> - 2015-10-31 23:00 -0400

csiph-web