k-means as Alternating Optimization

k-means minimizes E(y1,…,yk) = ∑i minc ‖xi − yc‖2 by alternating between two easy sub-problems: (1) fix the centers and reassign each point to its nearest center, then (2) fix the assignment and move each center to the mean of its points. Click "Step" to run one sub-problem at a time and watch the energy on the right only ever go down.

Data & Clusters

Click to add a data point xi (click a point again to remove it).
Add points, then "Random Init Centers".

Energy vs. Step

E = total squared distance to assigned centers. Every sub-problem can only decrease it.
no steps yet