KMEAS

You might also like

You are on page 1of 1

X<-mvrnorm(n=100,mu=c(5,5),Sigma=matrix(c(1/2,0,0,1/2),nrow=2,ncol=2))

Y<-mvrnorm(n=100,mu=c(6.5,8),Sigma=matrix(c(1/2,0,0,1/2),nrow=2,ncol=2))

Z<-mvrnorm(n=100,mu=c(6.5,8),Sigma=matrix(c(1/2,0,0,1/2),nrow=2,ncol=2))

datos<-rbind(X,Y,Z)

plot(datos)

kmeans.res<-kmeans(datos,centers=3)

plot(datos,col=kmeans.res<-kmeans.res$cluster)

points(kmeans.res$centers,cex=2,col=11,pch=19)

points(matrix(colMeans(datos),nrow=1,ncol=2),cex=3,col=12,pch=19)

kmeans.res$totss

kmeans.res$betweenss

kmeans.res$withinss

kmeans.res$tot.withinss

You might also like