FUNCTION REFERENCE

kmedoids

Partition around observations using PAM BUILD and SWAP.

Partition around observations using PAM BUILD and SWAP.

Syntax

[idx,C,sumd,D,midx] = kmedoids(X,k,'Algorithm','pam')

Distances use the pdist metric names or a handle @(xi,XJ) returning one column. Replicates and MaxIter are accepted. Start is 'plus', 'sample', 'cluster', or a matrix of distinct observed rows. The default uses greedy BUILD, followed by best improving SWAP steps; the best replicate minimizes total sumd. midx indexes medoids in original X. NaN rows are excluded and have NaN idx and D. rng controls random starts.

Example

[i,c,s,d,m] = kmedoids([0;1;2;9;10;11],2,'Algorithm','pam');   % c = [1;10]

Differences from MATLAB: Only PAM is implemented; other algorithms are not supported yet. The default is Euclidean distance with greedy BUILD initialization. Start='cluster' runs preliminary PAM on a random 10-percent sample (at least k rows). N-D starts are not supported yet. Distances are cached in a bounded square workspace.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.