Pairwise Distance Matrix

バージョン 1.9.0.0 (499 Bytes) 作成者: Mo Chen
Compute pairwise square Euclidean or Mahalanobis distances between points sets (fully optimized!).
ダウンロード: 4.2K
更新 2016/3/13

ライセンスの表示

This function computes pairwise distance between two sample sets and produce a matrix of square of Euclidean or Mahalanobis distances. The code is fully optimized by vectorization. Therefore it is much faster than the built-in function pdist.
When two matrices A and B are provided as input, this function computes the square Euclidean distances between them. If an extra positive definite matrix M is provided, it computes Mahalanobis distances.

If only one matrix A is provided, the function computes pairwise square Euclidean distances between vectors in A. In this case, it is equivalent to the square of pdist function in matlab statistics toolbox but much faster.

Sample code:
d=1000;n1=5000;n2=6000;
A=rand(d,n1);B=rand(d,n2);
M=rand(d,d);M=M*M'+eye(d);
D1=sqdist(A,B);
D2=sqdist(A);
D3=sqdist(A,B,M);

Detail explanation can be found in following blog post:
http://statinfer.wordpress.com/2011/11/14/efficient-matlab-i-pairwise-distances/

This function is now a part of the PRML toolbox (http://www.mathworks.com/matlabcentral/fileexchange/55826-pattern-recognition-and-machine-learning-toolbox).

引用

Mo Chen (2024). Pairwise Distance Matrix (https://www.mathworks.com/matlabcentral/fileexchange/24599-pairwise-distance-matrix), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2016a
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersStatistics and Machine Learning Toolbox についてさらに検索
謝辞

ヒントを得たファイル: Pattern Recognition and Machine Learning Toolbox

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

sqdist/

バージョン 公開済み リリース ノート
1.9.0.0

Cleaning up
minor tweak
update description

1.6.0.0

update description

1.5.0.0

update title and description

1.4.0.0

remove any redundant error check

1.3.0.0

update to support Mahalanobis distance. fix a bug for one dimensional case.

1.2.0.0

Add a centerization step for robustness purpose. Split the code for different number of input for efficiency purpose. Update comments.

1.1.0.0

update the description

1.0.0.0