Hi. I'm using scipy.spatial.distance.pdist. I was wondering if it was possible to invert the result to get the elements of the input matrix that produced a given result. Let me explain a little. Say we have a,b, c and d. The possible distances are ab, ac, ad, bc, bd and cd. pdist will give the values for those 6 distances. Say the largest is at index 5. How can I get from the pdist result array that it is the bd distance? And if it is not, is there another way of doing so? My data are such that I have close to 100k distances to compute. Thanks. Éric. Un clavier azerty en vaut deux ---------------------------------------------------------- Éric Depagne eric@depagne.org
I lost you on your description about the index of the largest distance. If what you are looking for is that given all pairwise distance ab, ac, ad, bc, bd, cd to find the coordinates of a,b,c and d, then the problem you are looking for is multidimensional scaling (MDS). You will get lots of hits if you search for it. In general it does not have a unique solution. On the other hand if you had all pairs of dot products (or similarities) you can obtain the coordinates by an eigen decomposition of the pairwise dot product matrix. On Mon, Apr 16, 2012 at 9:55 AM, Éric Depagne <eric@depagne.org> wrote:
Hi.
I'm using scipy.spatial.distance.pdist.
I was wondering if it was possible to invert the result to get the elements of the input matrix that produced a given result. Let me explain a little.
Say we have a,b, c and d. The possible distances are ab, ac, ad, bc, bd and cd. pdist will give the values for those 6 distances. Say the largest is at index 5. How can I get from the pdist result array that it is the bd distance?
And if it is not, is there another way of doing so? My data are such that I have close to 100k distances to compute.
Thanks. Éric.
Un clavier azerty en vaut deux ---------------------------------------------------------- Éric Depagne eric@depagne.org _______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
Le jeudi 19 avril 2012 06:52:49, srean a écrit : Hi. Sorry for my unclear explanation. My choice of wording for the subject of my email was very poor, sorry for that. I have the coordinates of a,b,c and d from the start. What I needed (see the end of my message) was a way to find what are the two points for which their distance (given by pdist) is the largest. So in my cases, I have a, b, c and d, their coordinates, and pdist gives me the values ab, ac,ad bc, bd and cd. I can then extract the largest value (thus the longest distance). Then I want to find to which pair it corresponds.
I lost you on your description about the index of the largest distance. If what you are looking for is that given all pairwise distance ab, ac, ad, bc, bd, cd to find the coordinates of a,b,c and d, then the problem you are looking for is multidimensional scaling (MDS). You will get lots of hits if you search for it. In general it does not have a unique solution. On the other hand if you had all pairs of dot products (or similarities) you can obtain the coordinates by an eigen decomposition of the pairwise dot product matrix. I've kept googling since, and I've found that Ben Root did exactly what I need here:
http://old.nabble.com/unravel_index-for-pdist--p32151477.html Cheers, Éric.
On Mon, Apr 16, 2012 at 9:55 AM, Éric Depagne <eric@depagne.org> wrote:
Hi.
I'm using scipy.spatial.distance.pdist.
I was wondering if it was possible to invert the result to get the elements of the input matrix that produced a given result. Let me explain a little.
Say we have a,b, c and d. The possible distances are ab, ac, ad, bc, bd and cd. pdist will give the values for those 6 distances. Say the largest is at index 5. How can I get from the pdist result array that it is the bd distance?
And if it is not, is there another way of doing so? My data are such that I have close to 100k distances to compute.
Thanks. Éric.
Un clavier azerty en vaut deux ---------------------------------------------------------- Éric Depagne eric@depagne.org _______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
-- Un clavier azerty en vaut deux ---------------------------------------------------------- Éric Depagne edepagne@aip.de Leibniz-Institut für Astrophysik Potsdam An der Sternwarte 16 14482 Potsdam Germany ----------------------------------------------------------
participants (3)
-
srean -
Éric Depagne -
Éric Depagne