Also called Lloyd's algorithm and k-means clustering.
test yourself
Six questions, four to pick from and two for paper. A point such as 7 6 stands 7 across and 6 up. In each figure, the crosses are the starting centres. Each answer stays hidden until you open it.
Six points, 1 1, 2 1, 1 3, 7 6, 8 8 and 9 6, with two centres started at 1 1 and 2 1. How many rounds until no centre moves?
the answer, and why
the answer is A
In round 1, the first centre takes 1, 1 and 1, 3 and moves to 1, 2; the second takes the rest and moves to 6.5, 5.25. In round 2, the point 2, 1 joins the first group, and both centres move again. Round 3 changes nothing.
if you chose another
BRound 2 still moves both centres, so a third round is needed to see none move.
CRound 1 moves both centres, so it cannot be the last.
DThat is how many points there are.
2question 2
On the same points and centres, how many distances are measured in all?
the answer, and why
the answer is A
Each round measures 6 points against 2 centres, 12 distances, and there are 3 rounds.
if you chose another
BThat is one round only.
CThat counts 3 rounds of one distance a point.
DThat is one distance a point, once.
3question 3
On the same points, how far does the second centre move in round 1?
the answer, and why
the answer is C
Its points are 2 1, 7 6, 8 8 and 9 6, whose middle is 6.5, 5.25. From 2, 1 that is 4.5 across and 4.25 up, the root of 38.31, about 6.19.
if you chose another
AThat is how far the first centre moves in round 1.
BThat is how far the second centre moves in round 2.
DThat is how far the first centre moves in round 2.
4question 4
Which is true of k-means?
the answer, and why
the answer is C
It stops when no centre moves, and where it stops depends on where the centres start.
AOn the learn page, section 7, the same four points started top and bottom settle at 64, while left and right give 16.
BSuch a centre stays where it is.
DEach round measures each point against every centre, k distances a point.
pen and paper
5question 5about 12 minutes
Four points, 1 3, 1 7, 9 3 and 9 7. Run k-means twice, once from centres 5 3 and 5 7, once from 2 5 and 8 5.
Write each point's group and each centre's place after each round.
How many rounds does each run take?
Work out each total squared distance. Which grouping is better?
a hint
A round in which no centre moves is the last.
a worked answer
From 5 3 and 5 7, the bottom points join the first centre and the top ones the second. Their middles are 5, 3 and 5, 7, where the centres already stand, so 1 round. Each of the 4 points is 4 from its centre, so the total is 4 times 4 squared, which is 64. From 2 5 and 8 5, the left points join the first centre and the right ones the second. The centres move to 1, 5 and 9, 5, and round 2 changes nothing, so 2 rounds. Each of the 4 points is 2 from its centre, so the total is 4 times 2 squared, which is 16. Left against right is better.
Nine points in three rows, 1 0, 2 0, 3 0, 1 5, 2 5, 3 5, 1 10, 2 10 and 3 10. The centres start at 2 0, 2 5 and 2 10.
Play the run round by round.
Count the distances, and check them against .
a hint
Each row is closer to itself than to any other row.
a worked answer
Round 1: each point joins its own row's centre, 3 rows of 3. Each row's middle is 2 across, where its centre already stands, so no centre moves and the run stops. It measures 9 points against 3 centres, 27 distances. for 9 points is 27.
Question 1: points in three rows far apart, one above another, each spread evenly about the same middle across, and each centre started at its row's middle. How many distances, ?7 of 7 shown
1the move: one round, and nothing moves
the line:
Six points in three rows, each centre started at its row's middle, 1 across. Round 1 moves no centre.
why it is allowed: Each centre starts level with its row. Another row's centre is just as far across and farther up or down, so every point's nearest centre is its own row's. Each row is spread evenly about its centre, so its middle is where the centre already stands. If n is under 3, a row may have no points; that centre stays where it is. No centre moves, and the method stops.
2the move: count the one round
the line:
why it is allowed: is the distances measured. By line 1 there is one round, and it measures each of the points against each of the 3 centres. For the six points, 18.
guess it, then
3the move: a ceiling
the line:
why it is allowed: By line 2, is , so it is at most .
guess it, then
4the move: read it as a bound
the line:
why it is allowed: By line 3, is at most 3 times .
guess it, then
5the move: a floor
the line:
why it is allowed: By line 2, is at least too.
guess it, then
6the move: read it as a bound
the line:
why it is allowed: By line 5, never drops below 3 times .
guess it, then
7the move: ceiling and floor together
the line:
why it is allowed: Lines 4 and 6 bound by the same growth, .
guess it, then
try it with a small : at , line 2 gives , which you can work out by hand