Does k-means always converge, and does it find the global optimum?

Unsupervised learning, Clustering
Level L2 Elementary. Length Short. Nature Th+Mat Both.

What's being asked

Whether you can give the coordinate-descent argument and know its limits.

Key idea

The k-means algorithm is coordinate descent on J=∑i∥xi−μci∥2, where ci is the cluster of point xi and μci is that cluster’s centre. Coordinate descent means minimising over one group of variables at a time. Neither step increases J, and there are finitely many assignments, so it stops after finitely many steps, but only at a local optimum.

Steps

  1. Write the objective J(c,μ).
  2. Assignment step: send each point to its nearest centre. This minimises J over the assignments c with μ fixed.
  3. Update step: the cluster mean minimises J over μ with c fixed.
  4. Since J never increases and there are finitely many partitions, the algorithm terminates.
  5. Finding the global optimum is NP-hard in general, so no efficient exact algorithm is expected. Use k-means++ initialisation and several restarts.

Common mistakes

How long your answer should be

4–6 sentences.

Last checked on 4 December 2026.

Read this

Previous in Unsupervised learning: What is collaborative filtering, and how do user-based and item-based neighbourhood methods differ? Which one scales better when there are far more users than items, and why?
Next in Unsupervised learning: What is k-means++ initialisation, and for the 1-D points {0,1,2,10,11} with k=2, if the first centre chosen is 0, what is the probability that each remaining point becomes the second centre?