PSA: Part and Select Algorithm

Partitions the points X into K clusters and also returns the K more representative points.
331 Downloads
Updated 14 Jun 2012

View License

PSA Part and Select Algorithm for clustering

IDX = PSA(X,K) partitions the points in the N-by-P data matrix X
into K clusters. This partition minimizes the diameter, over all clusters, of
the maximum difference between points in a certain dimension P of X.
Rows of X correspond to points, columns correspond to variables.
Note: when X is a vector, PSA treats it as an N-by-1 data matrix,
regardless of its orientation. PSA returns an N-by-1 vector IDX
containing the cluster indices of each point. By default, PSA uses
squared Euclidean distances.

[IDX, MEMBERS] = PSA(X,K) returns the K more representative MEMBERS


[IDX, MEMBERS, MAX] = PSA(X,K) returns the K cluster maximum diameter difference
MAX for each cluster.

[IDX, MEMBERS, MAX, DIM] = PSA(X,K) returns the dimension of the K cluster
maximum diameter difference

Examples:

X = [randn(30,2)+2.5;randn(30,2)-2.5];
subplot(1,2,1); plot(X(:,1),X(:,2),'bo');
IDX = psa(X,4);
subplot(1,2,2); plot(X(IDX==1,1),X(IDX==1,2),'bo');
hold on;
plot(X(IDX==2,1),X(IDX==2,2),'ro');
plot(X(IDX==3,1),X(IDX==3,2),'go');
plot(X(IDX==4,1),X(IDX==4,2),'ko');

F = (exp(1-(rand(200,1)*(7)+1)/4*(linspace(-1,1,55)))+((rand(200,1)*(7)+1)*ones(1,55)).*sin((rand(200,1)*(7)+1)*(linspace(-1,1,55))));
subplot(1,2,1);
plot(linspace(-1,1,55),F); xlim([-1 1]);
IDX = psa(F,6);
colors = {'b-' 'g-' 'r-' 'c-' 'm-' 'y-'};
subplot(1,2,2);
for i=1:6 plot(linspace(-1,1,55),F(IDX==i,:),colors{i}); hold on; xlim([-1 1]); end


See also: kmeans

$Author: Alan de Freitas $ $Date: 2012/06/11 $ $Revision: 1.0 $
Copyright: 2012
http://www.mathworks.com/matlabcentral/fileexchange/authors/255737

Cite As

Alan de Freitas (2024). PSA: Part and Select Algorithm (https://www.mathworks.com/matlabcentral/fileexchange/37131-psa-part-and-select-algorithm), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2011a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.1.0.0

Adding references

1.0.0.0