The kmeans command is an efficient implementation of k-means algorithm for clustering numerical multidimensional data.
d:=5:; n:=2500:; data:=[]:; |
C:=[[5,6],[14,10],[27,5],[10,21],[30,-2]]:; |
R:=[[2,2.5],[1.2,1],[3,3],[2,1.8],[1,0.5]]:; |
for k from 1 to n do |
j:=rand(d); |
x:=sample(randvar(normal,C[j][0],R[j][0])); |
y:=sample(randvar(normal,C[j][1],R[j][1])); |
data:=append(data,[x,y]); |
od:; |
kmeans(data,index="calinski-harabasz",output=plot) |