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
 
> dados<-matrix(c(-1,0,2,2.5,7,9,0,3,0,6,1,4),6,2)
> dados
     [,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
> plot(dados)
> dados<-matrix(c(-1,0,2,2.5,7,9,0,5,0,6,1,4),6,2)
> plot(dados)
> A<-kmeans(dados,dados[c(3,4),],1)
> A
$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

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to