3
$\begingroup$

Can you suggest any quick and simple clustering analyses, for univariate real-valued data? In other words, I have $n$ real numbers, $x_1,\dots,x_n$ where $x_i \in \mathbb{R}^+$, and I want to cluster them. I don't know a priori the best number of clusters, so that's something the method would need to discover as well.

It'd be nice if it were simple to code up in Python. Something quick and dirty -- say, easy to understand, easy to implement, and pretty effective-- beats something complex but optimal.


My motivation: As mentioned elsewhere, in the application in front of me now, a reasonable model would be to say that the points were generated from a mixture of Gaussians. I don't know the parameters of the mixture model, but if it helps, I can reasonably assume some lower bound on the probability of each component: for instance, if you like concrete numbers, you could imagine I have $n=40,000$ samples and each component of the mixture model is guaranteed to have proability at least $0.0001$. A twist is that there may be a few outliers thrown in as well, and I want to detect the outliers. @whuber suggested that a good approach to outlier detection would be to start by clustering the points, so I'm looking for quick-and-dirty clustering methods. That's my motivation at the moment -- but I expect the broader question is of general, independent interest, so feel free to ignore this specific motivation.

$\endgroup$
5
  • $\begingroup$ Do you mean that you want to bin your data? I cluster when I have multiple variables, not one. $\endgroup$
    – Michelle
    Commented Feb 13, 2012 at 4:29
  • $\begingroup$ @Michelle, I don't know (I'm not familiar with binning in this context). Perhaps the issue is that I don't know a priori what range to assign to each bin? Yeah, I realize clustering is usually applied to multivariate data; I would expect univariate clustering to be even easier, and I was hoping there might be some simple algorithms for it. $\endgroup$
    – D.W.
    Commented Feb 13, 2012 at 4:55
  • $\begingroup$ Hi again, I thought you were given some examples on what to do to look at your data for outliers, in the previous question. Are you having problems implementing those suggestions in Python? $\endgroup$
    – Michelle
    Commented Feb 13, 2012 at 5:04
  • 2
    $\begingroup$ Use the search function also on stackoverflow.com itself. I've seen this question come up quite often. Most often "one dimensional" instead of "univariate" though. See e.g. stackoverflow.com/a/8946299/1060350 $\endgroup$ Commented Feb 13, 2012 at 7:06
  • $\begingroup$ This post on Stack Overflow should answer your question: stackoverflow.com/questions/35094454/… $\endgroup$ Commented Jun 25, 2021 at 15:11

0

Your Answer

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