K-means by hand

Apply Lloyd’s algorithm to the one-dimensional data 0,1,3,8,9,11 with K=2 and initial centres 0 and 1. Report the partition after each pass and the final value of \widetilde W.

Alternate two operations: assign using the current centres, then recompute means using the new assignments. Evaluate the objective after the mean update.

Pass 1, centres 0 and 1. The point 0 goes to cluster 1. The points 1,3,8,9,11 go to cluster 2. For x=3 the squared distances are 9 versus 4, so 3 joins the centre at 1. The partition is \{0\} and \{1,3,8,9,11\}, with means 0 and 6.4. Its unweighted sum of squares is

\widetilde W=0+(5.4^2+3.4^2+1.6^2+2.6^2+4.6^2) =0+(29.16+11.56+2.56+6.76+21.16)=71.2.

Pass 2, centres 0 and 6.4. Compare squared distances: x=1 gives 1 versus 29.16, so cluster 1; x=3 gives 9 versus 11.56, so cluster 1; x=8 gives 64 versus 2.56, so cluster 2. The partition is \{0,1,3\} and \{8,9,11\}, with means 4/3 and 28/3.

Pass 3. For x=3,

(3-4/3)^2=25/9\approx 2.78, \qquad (3-28/3)^2\approx 40.1,

so x=3 stays in cluster 1. For x=8, 44.4 versus 1.78, so x=8 stays in cluster 2. No assignment changes, and the algorithm stops. The final value is

\widetilde W=\frac{16+1+25}{9}+\frac{16+1+25}{9}=\frac{84}{9}=9.33.

The criterion fell from 71.2 to 9.33.