How to use this calculator
Perform one Lloyd-style K-means assignment and centroid update for two-dimensional points and starting centers.
- Enter Point x coordinates, Point y coordinates, Initial center x coordinates, Initial center y coordinates. Match the units shown beside each field and review the result together with the assumptions below.
- Read the worked example below to check the expected input format and result.
- Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
How One k means assignment and update calculator works
Perform one Lloyd-style K-means assignment and centroid update for two-dimensional points and starting centers.
Inputs and units
- Point x coordinates: Enter one x coordinate per point; the coordinate list must match the y list.
- Point y coordinates: Enter one y coordinate per point in the same order as x.
- Initial center x coordinates: Enter each center's x coordinate; center count must match the center y list.
- Initial center y coordinates: Enter each center's y coordinate in matching center order.
Formula and method
Assign each point to its nearest center by squared Euclidean distance; replace each nonempty center by the coordinate-wise mean of its assigned points.
Worked example
Points (0,0), (1,0), (9,0), (10,0) with centers (0,0) and (10,0) split into the first two and last two points. The updated centers are (0.5,0) and (9.5,0).
Interpreting the result
The updated coordinates are centroids for this single assignment step. Repeating assignment and update can change memberships until convergence.
Assumptions and limits
This is one iteration, not a full model fit. Results depend on initialization and Euclidean distance; feature scales matter. An empty cluster retains its prior center in this implementation. K-means is sensitive to outliers and does not guarantee globally optimal clusters.
Sources and method
- Nearest-center assignment and centroid update in Lloyd-style K-means. scikit-learn K-means clustering
Frequently asked questions
Why can a later K-means step change these centers?
The next assignment uses the updated centers, so points near a boundary may switch groups before another mean update.
What happens when a cluster receives no points?
This calculator retains that cluster's starting center for the step rather than computing a mean of an empty set.
How do I use the One k means assignment and update calculator?
Enter Point x coordinates, Point y coordinates, Initial center x coordinates, Initial center y coordinates. Match the units shown beside each field and review the result together with the assumptions below.
What is a worked example of One k means assignment and update?
Points (0,0), (1,0), (9,0), (10,0) with centers (0,0) and (10,0) split into the first two and last two points. The updated centers are (0.5,0) and (9.5,0).
What does the One k means assignment and update calculator calculate?
Perform one Lloyd-style K-means assignment and centroid update for two-dimensional points and starting centers.