You should have a look at the K-means clustering algorithm, which produces what you are looking for.
julien
- 10.3k
- 6
- 56
- 94