Let's say I have a list of numeric values that tend to be grouped into some number of clusters of values that are close to one another.

I'm aware of things like k-means to group these into groups of similar values, but I'm curious as to whether there's a faster and perhaps simpler algorithm to simply find all the values in the first or lowest valued cluster.

Example: take this sequence:


There are three clusters: one near about 10, one near 20, and one near 42. The algorithm in question might return:


These values are part of the lowest valued cluster of grouped values. Whether the results are sorted or not doesn't matter.

I can think of some easy improvised ways but I'm wondering if there's a robust general solution.

  • $\begingroup$ For a simple task like this, k-means should be good because robust and fast enough. Maybe DBSCAN can be faster? But it requires hyperparameters that are not so easy to determine, it depends on your knowledge over the data. May I ask why you want something faster? (need to perform it several times, on a large dataset, just curiosity?) $\endgroup$ Oct 31, 2019 at 22:15

1 Answer 1


Sort your data. That is the fast trick that you cannot do on multivariate data. Then solid for r by three largest gaps or using KDE.

Clustering is more interesting for multivariate data.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.