Re: [Numpy-discussion] distance matrix and (weighted) p-norm

2008-09-08 Thread Damian Eads
Emanuele Olivetti wrote: Hi, I'm trying to compute the distance matrix (weighted p-norm [*]) between two sets of vectors (data1 and data2). Example: import numpy as N p = 3.0 data1 = N.random.randn(100,20) data2 = N.random.randn(80,20) weight = N.random.rand(20) distance_matrix =

Re: [Numpy-discussion] distance matrix and (weighted) p-norm

2008-09-08 Thread Emanuele Olivetti
Damian Eads wrote: Emanuele Olivetti wrote: ... [*] : ||x - x'||_w = (\sum_{i=1...N} (w_i*|x_i - x'_i|)**p)**(1/p) This feature could be implemented easily. However, I must admit I'm not very familiar with weighted p-norms. What is the reason for raising w to the p instead of

Re: [Numpy-discussion] distance matrix and (weighted) p-norm

2008-09-07 Thread Damian Eads
Hi there, The pdist function computes pairwise distances between vectors in a single collection, storing the distances in a condensed distance matrix. This is not exactly what you want--you want to compute distance between two collections of vectors. Suppose XA is a m_A by n array and XB is

Re: [Numpy-discussion] distance matrix and (weighted) p-norm

2008-09-07 Thread Emanuele Olivetti
Excellent. David said that distance computation will be moved in a separate package soon. I guess that your implementation will be the suitable one for this package. Am I wrong? Thanks again, Emanuele Damian Eads wrote: Hi there, The pdist function computes pairwise distances between

Re: [Numpy-discussion] distance matrix and (weighted) p-norm

2008-09-07 Thread Jarrod Millman
On Sun, Sep 7, 2008 at 4:07 PM, Emanuele Olivetti [EMAIL PROTECTED] wrote: David said that distance computation will be moved in a separate package soon. I guess that your implementation will be the suitable one for this package. Am I wrong? Yes, that is correct. David was talking about

Re: [Numpy-discussion] distance matrix and (weighted) p-norm

2008-09-03 Thread Emanuele Olivetti
David Cournapeau wrote: Emanuele Olivetti wrote: Hi, I'm trying to compute the distance matrix (weighted p-norm [*]) between two sets of vectors (data1 and data2). Example: You may want to look at scipy.cluster.distance, which has a bunch of distance matrix implementation. I believe

Re: [Numpy-discussion] distance matrix and (weighted) p-norm

2008-09-03 Thread David Cournapeau
Emanuele Olivetti wrote: Thanks for the pointer but the distance subpackage in cluster is about the distance matrix of vectors in one set of vectors. So the resulting matrix is symmetric. I need to compute distances between two different sets of vectors (i.e. a non-symmetric distance matrix).

Re: [Numpy-discussion] distance matrix and (weighted) p-norm

2008-09-03 Thread Emanuele Olivetti
David Cournapeau wrote: FWIW, distance is deemed to move to a separate package, because distance computation is useful in other contexts than clustering. Excellent. I was thinking about something similar. I'll have a look to the separate package. Please drop an email to this list when

[Numpy-discussion] distance matrix and (weighted) p-norm

2008-09-02 Thread Emanuele Olivetti
Hi, I'm trying to compute the distance matrix (weighted p-norm [*]) between two sets of vectors (data1 and data2). Example: import numpy as N p = 3.0 data1 = N.random.randn(100,20) data2 = N.random.randn(80,20) weight = N.random.rand(20) distance_matrix = N.zeros((data1.shape[0],data2.shape[0]))

Re: [Numpy-discussion] distance matrix and (weighted) p-norm

2008-09-02 Thread David Cournapeau
Emanuele Olivetti wrote: Hi, I'm trying to compute the distance matrix (weighted p-norm [*]) between two sets of vectors (data1 and data2). Example: You may want to look at scipy.cluster.distance, which has a bunch of distance matrix implementation. I believe most of them have optional