I'm trying to cluster set of histograms. The histograms represent the frequencies of the distribution for a numbers from 1 to 5. The following figure shows two samples of my data.

enter image description here

I have 10,000 histograms with fixed number of bins (5) and I'm looking for a simple clustering algorithm implemented in MATLAB, C# or C++, that can take the histograms and cluster them.

  • 1
    $\begingroup$ Take a look here and here. I couldn't find an ungated copy of the second article. $\endgroup$ – shadowtalker May 15 '15 at 16:20
  • $\begingroup$ Unfortunately, the second article is worth a mint. :) Thanks for this links! $\endgroup$ – Michael Dorner Jul 25 '15 at 10:02
  • $\begingroup$ I might try to use PCA to group them. It is 5-dimensional continuous data, and you are trying to pack it into discrete bins. $\endgroup$ – EngrStudent Dec 23 '16 at 23:27

Use hierarchical clustering or DBSCAN.

They have one huge benefit over k-means: they work with arbitrary distance measures, and with histograms you might want to use like, for example, Jensen-Shannon divergence, etc. that are designed to capture the similarity of distributions.


K-means could do this. K-means is an unsupervised clustering algorithm. Rewrite each histogram as a vector and use Euclidean distance.

This post goes into the assumptions of K-means: How to understand the drawbacks of K-means You might want to check these.

You have to determine the number of clusters yourself by estimating models with different k.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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