Lloyd's algorithm 2026-11-05
Lloyd's algorithm alternates two updates to reduce squared-distance distortion for a fixed number of centers: assign each data point to a nearest center, then replace each nonempty cluster's center by its arithmetic mean. For a probability distribution, the corresponding center is the conditional expectation on the assigned region. The scalar quantization problem was the motivation in Stuart P. Lloyd's paper.[ref]
Least Squares Quantization in PCM by Stuart P. Lloyd. Sections IV–VI, printed pages130–132, equations14 and17 and Quantization Procedures
Write the objective as , where identifies the assigned center. With centers fixed, each point minimizes its own contribution by choosing a nearest center. For a nonempty cluster , its arithmetic mean satisfiesThus the center update minimizes the contribution for fixed assignments. Both steps make nonincreasing, but this does not guarantee a global minimum.
An original example makes initialization matter. For the six scalar data points , two initial centers give a boundary at . Assign the tied value to the first center. The clusters become and , with means . Their new boundary is , preserving the assignments, and .
Instead initialize at . The boundary gives clusters and . Their means have boundary , again preserving the assignments, but now . This second fixed configuration cannot be globally optimal because the first is a better feasible configuration. Lloyd explicitly distinguishes stationary configurations from the absolute optimum.[ref]
Least Squares Quantization in PCM by Stuart P. Lloyd. SectionVI and AppendixB: necessary conditions, saddle points and multiple minima
An implementation must specify tie handling and what to do with empty clusters, whose arithmetic means are undefined. Objective decrease is a useful check; it does not certify discovery of a unique underlying grouping.
Stuart P. Lloyd 2026-11-05
Stuart P. Lloyd developed conditions and an iterative procedure for minimizing squared error in quantization. His paper Least Squares Quantization in PCM by Stuart P. Lloyd, published in 1982, identifies Bell Laboratories as his affiliation and records a presentation of part of the work in 1957. The motivating problem was pulse-code modulation: representing a signal sample by one of finitely many reconstruction values.[ref]
Least Squares Quantization in PCM by Stuart P. Lloyd. Page 129, author footnote and introduction
The central conditions have a clear interpretation. For fixed reconstruction values, assign an input to a nearest value. For fixed assignment regions of positive probability, place each reconstruction value at the corresponding conditional expectation. Alternating these operations gives Lloyd's algorithm; neither operation increases the mean squared error, but this does not guarantee the global optimum from every initialization.[ref]
Least Squares Quantization in PCM by Stuart P. Lloyd. Sections IV–VI: best quanta, best partition and an algorithm
For an original example, take a continuous uniform distribution on and two reconstruction values. Splitting at zero gives conditional means and , whose midpoint is again zero. The mean squared error isUsing the single reconstruction value zero instead gives . This concrete improvement explains the optimization objective: preserve signal amplitudes accurately with a limited collection of values.