PSA: Part and Select Algorithm

Partitions the points X into K clusters and also returns the K more representative points.
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


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;

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))));
plot(linspace(-1,1,55),F); xlim([-1 1]);
IDX = psa(F,6);
colors = {'b-' 'g-' 'r-' 'c-' 'm-' 'y-'};
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

Cite As

Alan de Freitas (2024). 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

Adding references