Math
k-means clustering
Step through k-means assignments and centroid updates, move centres manually and compare cluster counts on an elbow curve.

Try this
Alternate centroid updates and nearest-centroid assignments. Click the cloud to move the nearest centroid. Empty clusters keep their previous centre. The lower elbow curve shows the best of five k-means++ runs for each k; local minima can still occur.
Equations used in the module
Equations J = Σᵢ ||xi−μlabel(i)||² Assignment: label(i) = argminⱼ ||xi−μj||² Update: μj = mean of points assigned to j Each Lloyd half-step cannot increase J; global minimum is not guaranteed


