Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

PSet 27: K-Means Clustering

(videos: k-means)

The following data was drawn from two normal distributions with different randomly selected means:

[[ 1.2  -1.0 ]
 [-0.7   2.1 ]
 [-0.2  -0.07]
 [-2.4   2.4 ]
 [ 1.1   0.4 ]
 [-3.6   0.8 ]
 [ 0.6  -1.1 ]
 [ 0.01 -0.8 ]
 [ 1.0  -0.1 ]
 [-1.9   0.9 ]]

With a k of 2, and the initial means of [-1, 1] and [-0.9, 1.1], run the k-means algorithm for one iteration. Clearly write out your two resulting clusters. Calculate the new centroids. What are their new centroid values?


Run a second iteration. Write out the new clusters and the new centroid values.


Run a third iteration. Did the clusters change? Write out the final clusters and centroid values.