Skip to content
Prev 32848 / 398513 Next

kmeans

Dear helpers
 
I was working with kmeans from package mva and found some strange situations. When I run several times the kmeans algorithm with the same dataset I get the same partition. I simulated a little example with 6 observations and run kmeans giving the centers and making just one iteration. I expected that the algorithm just allocated the observations to the nearest center but think this is not the result that I get...
 
Here are the simulated data
[,1] [,2]
[1,] -1.0    0
[2,]  0.0    3
[3,]  2.0    0
[4,]  2.5    6
[5,]  7.0    1
[6,]  9.0    4
$cluster
[1] 1 1 1 1 2 2
$centers
   [,1] [,2]
1 0.875 2.75
2 8.000 2.50
$withinss
[1] 38.9375  6.5000
$size
[1] 4 2
 
 
Any hints?
 
Thanks a lot 
 
Luis Silva