One-dimensional K-means iteration bound 2026-10-25
For distinct observations on the real line and , nearest-centre assignment produces contiguous blocks of the sorted observations because each Voronoi cell is an interval. The arithmetic means of distinct ordered blocks are strictly ordered, preserving this property at subsequent assignments. Initialize at distinct observed values so that the initial assignment has no empty cluster.
The empty-cluster repair in finite termination of K-means clustering also preserves contiguous blocks: an observation farthest from a centre over its assigned block lies at one of that block's endpoints, so transferring it to a new singleton splits the block into two contiguous blocks.
There are possible partitions into nonempty blocks: choose cuts among the gaps. Under the stable tie rule in finite termination of K-means clustering, every round after the first strictly reduces the objective until stopping, so a block partition cannot recur. The number of assignment, repair, and centre-update rounds is therefore at most . Check stability after each update without an additional update round; for , one update suffices.
Write for row of the data matrix. The k-means clustering objective is the within-cluster sum of squared Euclidean distances:The nonempty form a partition of a set of observation indices. For fixed clusters, part (a) shows that the best is their centroid.
Initialize distinct centres, for example by choosing distinct observations. Then repeat the following steps:
- Assign each observation to a nearest centre in Euclidean distance. Keep its current assignment on an exact tie; for a previously unassigned observation use a fixed ordering to resolve ties.
- If a cluster is empty, choose an observation from a cluster with at least two members and make it the empty cluster's sole member, placing its centre at that observation. A definite rule is to choose an eligible observation farthest from its currently assigned centre, breaking ties by observation index. Repeat until all clusters are nonempty.
- Replace each centre by the arithmetic mean of its assigned observations.
- After updating, check whether every observation is still assigned to a nearest updated centre, retaining its assignment on ties. If so, stop; otherwise repeat.
The empty-cluster repair is possible for and cannot increase : the transferred observation now has squared distance zero, while all other squared distances stay unchanged before the centre update.
Assignment cannot increase , and any changed assignment strictly decreases it under the tie rule. Updating centres cannot increase by the centroid sum-of-squares identity. After an update, the centres are determined by the partition of a set. There are only finitely many possible assignments. Unless this is the initial round, any nonterminal round starts with an assignment that strictly reduces ; repairing empty clusters and updating cannot undo that decrease. Thus a partition cannot recur, proving finite termination of K-means clustering. The final result need not be a global minimum; different initial centres can lead to different final clusterings.
For observations , K-means clustering seeks nonempty clusters in cluster analysis and centroids minimizingAt fixed centroids, assigning each point to a nearest centroid minimizes its squared Euclidean distance. At fixed assignments, the centroid sum-of-squares identity shows that the sample mean uniquely minimizes each group's contribution. These alternating steps cannot increase .
For finite termination of K-means clustering, more than a lower bound on is needed. Keep an assignment unchanged when nearest centroids tie, and stop when assignments no longer change. Every change then strictly decreases . After updating the centroids, is determined by the partition of a set of indices; there are only finitely many choices for that partition of a set, so no strictly improving partition of a set can recur. Empty clusters in cluster analysis require a convention, such as moving a point from a nonsingleton cluster in cluster analysis to become its own centroid, which cannot increase . With such a consistent convention the algorithm terminates, although it may reach only a local minimum.