Hello, It's my first use of the distance function from scipy.spatial, and I wonder if there is an error in the docstring of pdist: http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.spatial.dis... (same thing for cdist) [...] Returns ------- Y : ndarray Returns a condensed distance matrix Y. For each :math:`i` and :math:`j` (where :math:`i<j<n`), the metric ``dist(u=X[i], v=X[j])`` is computed and stored in entry ``ij``. [...] Is this indeed the entry i*j ? Because the docstring of squareform says : [...] The X[i, j] and X[j, i] values are set to v[{n \choose 2}-{n-i \choose 2} + (j-u-1)] [...] best, Pierre
Hi Pierre, On Tue, Jan 13, 2015 at 1:20 PM, Pierre Haessig <pierre.haessig@crans.org> wrote:
Hello,
It's my first use of the distance function from scipy.spatial, and I wonder if there is an error in the docstring of pdist:
http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.spatial.dis... (same thing for cdist)
[...] Returns ------- Y : ndarray Returns a condensed distance matrix Y. For each :math:`i` and :math:`j` (where :math:`i<j<n`), the metric ``dist(u=X[i], v=X[j])`` is computed and stored in entry ``ij``. [...]
Is this indeed the entry i*j ? Because the docstring of squareform says :
I don't think that i*j is meant here but rather the typical mathematical matrix notation, in tex $X_{ij}$. I believe that you're right and this is also incorrect, i.e., it should be something along the lines of what you quote from the squareform documentation:
[...] The X[i, j] and X[j, i] values are set to v[{n \choose 2}-{n-i \choose 2} + (j-u-1)] [...]
I do fail to see what `u` is in this context, however.
best, Pierre
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-dev
So I think the docs should be improved. Care to submit a PR? Cheers, Moritz
Hi Moritz, Thanks for the feedback. Matlab doc for the equivalent pdist function is indeed clearer. http://www.mathworks.com/help/stats/pdist.html I believe you're right : the [ij] means [i,j] and this is wrong. It should be more the complex product given in squareform help (by the way Matlab gives an easier to read formula "/D/((/i/–1)*(/m/–/i//2)+/j/–/i/)". I should check whether it's equivalent after converting to 0-based indexing...) best, Pierre
participants (2)
-
Moritz Beber
-
Pierre Haessig