Visual walkthrough — K-Means++ initialization
Step 1 — What are we even looking at? Points on a sheet
WHAT. We have a bunch of dots scattered on a flat sheet of paper. Each dot is one data point. In our running example there are 9 dots that naturally form 3 little clumps: a clump on the lower-left, a clump on the lower-right, and a clump up top.
WHY. Before any maths, fix the object in your mind. Clustering means: draw a few flags (we will call them centroids) so that every dot is near a flag. A good set of flags has one flag inside each clump. A bad set has two flags in the same clump and a clump left with no flag nearby.
PICTURE. Look at the sheet below. The three clumps are drawn in cyan. There are no flags yet — that is the blank slate we start from.

We want to plant flags. Here .
Step 2 — Measuring "how far": the distance between two dots
WHAT. Pick two dots. The straight-line length between them is their distance. We write it .
WHY. Every judgement K-Means++ makes ("is this dot already covered by a flag?") is a judgement about distance. So we must nail down what distance is before anything else.
PICTURE. Below, dot sits at position — that just means " steps right, steps up". Flag sits at . The horizontal gap is (amber). The vertical gap is (amber). The straight line joining them (white) is the true distance — and by the right-triangle rule (Pythagoras) its length is the square root of the two gaps squared and added.

Step 3 — The first flag: pure luck
WHAT. We plant the first centroid by picking one dot at random, every dot equally likely.
WHY. With no flags on the sheet yet, we have no information about which region is under-served. Any starting dot is as good as any other, so the fair thing is a uniform coin-flip over all dots. Picking "the centre" or "the corner" would secretly bias the whole procedure.
PICTURE. Below, one dot in the lower-left clump has been chosen and marked with an amber flag . Notice: it landed inside one clump. That is the situation we must now repair — two clumps still have no flag near them.

Step 4 — The key quantity : distance to the nearest flag
WHAT. For every dot , we now compute = the distance from to the closest flag we have planted so far. If there is only one flag, is just the distance to it. If there are several, we keep the smallest.
WHY. A dot is "well covered" if some flag is near it — it does not matter that other flags are far. So we care only about the nearest flag. is small for a dot sitting on a flag, and large for a dot stranded in an empty region. That single number tells us exactly how badly each dot still needs a flag.
PICTURE. Below, from (amber) we draw a white line to each dot. For dots in the same clump as , the line is short (small ). For dots in the far clumps, the line is long (large ). Each line is labelled with its length.

Step 5 — Squaring: turning distance into hunger
WHAT. We square to get . This is the "hunger score" of a dot: how loudly it is asking for a nearby flag.
WHY square, not just use ? Two reasons, both visible.
- Same currency as the goal. K-Means' final quality is measured as a sum of squared distances (called inertia or cost). If we choose flags to attack squared distance, we are attacking exactly the quantity we will later be graded on.
- Aggressive spreading. A dot twice as far gets four times the hunger (), not twice. This makes the far, stranded clumps overwhelmingly loud compared to already-covered dots — which is precisely the spreading we want.
PICTURE. Below, two bars per dot: the thin cyan bar is , the fat amber bar is . Watch the far dots: doubling the cyan bar quadruples the amber bar. The gap between "near" and "far" dots explodes when we square.

Step 6 — From hunger scores to a fair lottery
WHAT. We now pick the next flag at random, but with a loaded die: a dot's chance of winning is its hunger divided by the total hunger of all dots.
WHY divide by the total? Chances must add up to (something has to be picked). The sum of all hunger scores, written ("phi"), is that total. Dividing each score by shrinks all scores so they sum to exactly while keeping their relative sizes — a hungry dot still gets a proportionally big slice.
PICTURE. Below is a "lottery wheel". Each dot owns a slice of the wheel; the slice size equals its share of the total hunger. The far clumps own huge slices; the already-covered clump owns a sliver. We spin once — wherever the amber pointer lands is .

Step 7 — Repeat: re-measure, then spin again
WHAT. After planting , we recompute for every dot — because now each dot measures its distance to the nearest of two flags. Then we build a new lottery wheel and spin for . We repeat until all flags are planted.
WHY recompute? Once the lower-right clump has a flag, its dots are suddenly well-covered — their hunger collapses to near zero. If we didn't re-measure, we might plant a second flag in a clump that no longer needs one. Re-measuring after every pick is what makes the flags fan out to different clumps.
PICTURE. Below, top panel: after (lower-left) and (lower-right) are down, the two lower clumps are quiet; only the top clump still has large . Bottom panel: the resulting wheel is almost entirely owned by the top clump, so almost surely lands there — one flag per clump. Done.

Step 8 — Edge and degenerate cases (what if the picture is weird?)
Real data is not always three tidy clumps. Here is what each corner case looks like and why the rule still holds.
Case A — a duplicate dot right on a flag. Its , so its hunger , so its lottery slice is zero. It can never be chosen as a new flag. Good — planting a flag on top of an existing flag would waste it.
Case B — a far-off outlier. Its hunger is enormous, so it owns a big slice — but not the whole wheel, because a big clump of merely-far dots collectively outweighs one lone stray. The lottery protects us. (Deterministic "pick the farthest" would fall for the outlier every time.)
Case C — all dots identical / already all at distance zero. Then and every slice is . The standard fix: when , fall back to a uniform pick (everyone equally likely). This only happens when data has fewer distinct points than — a signal you asked for too many clusters (compare with Elbow Method and Silhouette Score).
PICTURE. Below, three mini-sheets: (A) a duplicate on the flag with a zero-length line; (B) an outlier owning a large-but-not-total slice; (C) all dots stacked, wheel undefined → uniform fallback.

The one-picture summary
PICTURE. One diagram, the whole recipe: plant by fair coin → measure each dot's nearest-flag distance → square it into hunger → normalise into a lottery wheel → spin for the next flag → re-measure and repeat. The flags fan out, one per clump.

Recall Feynman retelling — say it to a 12-year-old
Imagine planting scarecrows in a field of crops so every crop has a scarecrow nearby. You drop the first scarecrow anywhere — you have no clue yet. Then, for every crop, you check how far it is from its nearest scarecrow. A crop with a scarecrow right beside it is happy; a crop alone in an empty corner is desperate. You square the desperation so the lonely corners scream four times louder when they're twice as far. Then you hold a raffle: each crop buys raffle tickets equal to its (squared) desperation, and you draw one winner — the next scarecrow goes there. Because empty corners bought way more tickets, the new scarecrow almost always lands where it's needed, but the raffle keeps it from being fooled by a single weird crop miles away. Re-check everyone's nearest scarecrow, run the raffle again, and keep going until you've planted them all. You end up with scarecrows spread neatly across the whole field — one per crowd — which is exactly the head-start that makes K-Means finish fast and clean.
Reveal checks
Why do we square instead of using directly?
What does stand for?
Why not just pick the single farthest point each time?
What do you do when total hunger ?
See also: K-Medoids (PAM) · Hierarchical Clustering · DBSCAN · Expectation-Maximization (EM) · Computational Complexity · 2.5.03 K-Means++ initialization (Hinglish)