KNNSEARCH search for K nearest neighbors
and related statistics
Usage:
IDX = knnsearch(X,Y);
finds for each element (row) in Y, the nearest
of all elements in X, such that
IDX(k) points to X(IDX(k),:) that is nearest to Y(k,:)
IDX has as many elements as Y has rows
[IDX,DIST] = knnsearch(X,Y);
... = knnsearch(...,'k',k);
search for k nearest neighbors (default: k=2)
... = knnsearch(...,'Scale',Scale);
Scaling vector of 'seuclidian' metric
default value is std(X)
... = knnsearch(...,'Cov',Cov);
Cov is the covariance matrix used for Mahalanobis distance
default value is cov(X)
... = knnsearch(...,'Distance',Distance);
the following distance metrics are currently supported:
'euclidean' [1],
'seuclidean', (scaled euclidian)
'minkowski' [3],
'cityblock' or 'manhattan' [4],
'hamming' [5],
'mahalanobis' [6],
'cosine' [7]
(one minus the cosine of the angle between the two samples),
'correlation'
(one minus the linear correlation between each pair f data vectors),
'spearman'
(one minus the rank correlation between each pair of data vectors),
SEE ALSO: corrcoef, spearman, rankcorr, cov, std
Reference(s):
[1] https://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm
[2] https://en.wikipedia.org/wiki/Euclidean_distance
[3] https://en.wikipedia.org/wiki/Minkowski_distance
[4] https://en.wikipedia.org/wiki/Taxicab_geometry
[5] https://en.wikipedia.org/wiki/Hamming_distance
[6] https://en.wikipedia.org/wiki/Mahalanobis_distance
[7] https://en.wikipedia.org/wiki/Cosine_similarity
Package: nan