Questions tagged [pdist]

pdist computes pairwise distance between pairs of objects in m-by-n data matrix in MATLAB.

pdist computes Euclidean distance between pairs of objects in m-by-n data matrix in .

Syntax

D = pdist(X)
D = pdist(X,distance)

Where, X is m-by-n data matrix.

  1. In D = pdist(X), the calculated distance is Euclidean distance.
  2. In D = pdist(X,distance) , the method can be specified by distance, which can be any one of the following
'euclidean'  
'seuclidean'  
'cityblock'  
'minkowski'  
'chebychev'  
'mahalanobis'    
'cosine'  
'correlation'  
'spearman'  
'hamming'     
'jaccard'  

or any custom distance function of form d2 = distfun(XI,XJ)

You should use this tag if your question is related to the use of pdist or any custom distance functions associated with it.

48 questions
0
votes
0 answers

Minimum distance between two matrices with coordinates in 3D

I have two matrices ((intx(i),inty(i),intz(i)) and Ceres(j)) with coordinates, and I need to find the two points closest to each other. From the MATLAB code I would expect to get the distance between the point in the first matrix, that is closest to…
Julie
  • 1
0
votes
0 answers

Matlab out of memory. Error using pdistmex

I have a matrix M of size(262322x4). On running knn imputation: M=csvread("C:\Users\Hello\Desktop\DATA\B.csv",1,0); B = transpose(M); A = knnimpute(B,1); C=transpose(A); I get the following error: >>knn_imputation Error using pdistmex Out of…
Jerry
  • 410
  • 6
  • 17
0
votes
3 answers

Plot distances between points matlab

I've made a plot of 10 points 10 10 248,628959661970 66,9462583977501 451,638770451973 939,398361884535 227,712826026548 18,1775336366957 804,449583613070 683,838613746355 986,104241895970 …
Rogier
  • 65
  • 1
  • 6
0
votes
2 answers

How to separately compute the Euclidean Distance in different dimension?

I got a question when using pdist, it would be so many thanks if you could give me some advice. The pdist(D) usually gives the sum of the distance for the multiple dimension, however, I want to get the distance separately. For example I have a data…
Zhida Deng
  • 189
  • 2
  • 12
0
votes
1 answer

Using pdist with a custom correlation function the right way to avoid kappa score discrepancies?

I read this but this is not solving my problem: I have this initial_comparison_frame id GO1 GO10 GO11 GO12 GO2 GO3 GO4 GO5 GO6 GO7 GO8 GO9 GO1 1 0 0 0 0 0 1 1 1 1 1 1 GO2 0 0 1 0 1 0 1 1 1 1 1 …
Ando Jurai
  • 1,003
  • 2
  • 14
  • 29
0
votes
1 answer

python how to get proper distance value out of scipy condensed distance matrix

I am using python 2.7 with scipy to calculate a distance matrix for an array. I don't get how to find the wanted distance values in the returned condensed matrix. See example from scipy.spatial.distance import pdist import numpy as np a =…
thebeancounter
  • 4,261
  • 8
  • 61
  • 109
0
votes
0 answers

scipy pdist variation performance boosting by applying to all pairs

I'm trying to apply a variation of pairwise euclidean distance calculation on a pandas dataframe to generate an edge list. A standard euclidean distance calculation can be: from scipy.spatial.distance import pdist from scipy.spatial.distance import…
leoce
  • 715
  • 1
  • 8
  • 24
0
votes
4 answers

Numpy array of distances to list of (row,col,distance)

I have an nd array that looks as follows: [[ 0. 1.73205081 6.40312424 7.21110255 2.44948974] [ 1.73205081 0. 5.09901951 5.91607978 1. ] [ 6.40312424 5.09901951 0. 1. 4.35889894] [ 7.21110255 …
Mike El Jackson
  • 771
  • 3
  • 14
  • 23
0
votes
1 answer

Is there a specific use of pdist function of scipy for some particular indexes?

my question is about use of pdist function of scipy.spatial.distance. Although I have to calculate the hamming distances between a 1x64 vector with each and every one of other millions of 1x64 vectors that are stored in a 2D-array, I cannot do it…
A Ef
  • 13
  • 2
  • 8
0
votes
1 answer

Implement Extended Jaccard Similairty in pdist MATLAB

I want to use pdist() in MATLAB and use a custom function "Extended Jaccard" defined as bellow: S_EJ(X_a, X_b) = (X_a . X_b) / (||X_a||^2 + ||X_b||^2 - X_a . X_b) where X_a . X_b represents the inner product between vectors X_a and X_b and ||…
Yas
  • 811
  • 4
  • 11
  • 20
0
votes
1 answer

Understanding the use of pdist in combination with mdscale

I am working on a clutering problem. I have a set of 100 observatons. Each observation is described by 3 features. I have to cluster these observations in 2 groups (I have a label for each observation). Before clustering the observations I computed…
gabboshow
  • 5,359
  • 12
  • 48
  • 98
0
votes
0 answers

Having trouble with pdist in R

I have two matrices: features.dataf[,2:4] which is a dataframe: alliterationScore consonanceScore concretenessScore 1 0.09467456 0.8224852 0.5508414 2 0.10547173 0.7286084 0.5067937 3 0.09533538…
QPTR
  • 1,620
  • 7
  • 26
  • 47
0
votes
1 answer

Measure distance between data set of 5D

I want to measure the distance (Euclidean) between data sets of 5 dimensions. It looks like this: center x 0 [0.09771348879, 1.856078237, 2.100760575, 9.25... [-1.35602640228e-12,…
Micheal
  • 17
  • 1
  • 7
0
votes
2 answers

Use linkage with custom distance

I would like to use the linkage function in matlab with a custom distance. My distance function is in the form: Distance = pdist(matrix,@mydistance); so given a matrix = rand(132,18) Distance will be a vector [1x8646]; D_matrix =…
gabboshow
  • 5,359
  • 12
  • 48
  • 98
0
votes
1 answer

matlab use my own distance function for pdist

I have a simple function to calculate the distance between two vectors, such that distance = dot product / sum of elements in the two vectors. function d = simpleDistance(a,b) d = dot(a,b)/ (sum(a) + sum(b)); end for example:…
CSawy
  • 904
  • 2
  • 14
  • 25