# What quality of a distribution describes the “spikiness” of its density, and how do I get a good density plot of a spiky distribution?

I'm a programmer, not a math guy, so please answer in English. ;)

Suppose I have a multi-modal univariate distribution like:

.. . ..                         ...........                    .. . .. .

but with each "cluster" (where each clusters is normally distributed) much further apart and more clusters. If I do a density plot of this with R, it's going to be spiky, but some of the less dense spikes might not be smooth because the "optimal" bandwidth was dominated by the more dense clusters.

Compare to a unimodal distribution like:

.          .         . ..    .  . . ... .. . .      .. .    .   .      .

The density plot of this distribution would look just fine.

What property describes the multi-modality of a distribution? I'm pretty sure that the former distribution would be better modeled by separating each cluster into a separate distribution and doing a density plot on it separately. But I'm unsure how to separate the distribution into these clusters robustly.

-
Are you trying to measure the skewdness? That would be characterized by kurtosis: en.wikipedia.org/wiki/Kurtosis – Alex R. Sep 18 '12 at 16:21
No: A high kurtosis distribution has a sharper peak and longer, fatter tails, while a low kurtosis distribution has a more rounded peak and shorter, thinner tails. I'm trying to measure the number of modes and separate the distribution into separate distributions for each mode. – Matt Chambers Sep 18 '12 at 16:27
Something like k-means then? Especially if you are expecting uniform clusters, each of your k-means would represent the mode of a particular cluster: en.wikipedia.org/wiki/K-means – Alex R. Sep 18 '12 at 16:33
That looks like a great way to do the actual separation into clusters. But how do I figure out whether I should apply it or not? In the unimodal distribution example I gave, I would not want to apply it. Also, move to an answer so I can mark it. – Matt Chambers Sep 18 '12 at 16:50
It's NP hard to actually figure out a good k-means approximation. One idea would be to help k-means by doing an initial peak detection algorithm. If you convolve your distribution with a sliding box function, it will effectively average out values at each point in the interval of the box. If you then set a threshold value for the set of averages, you'll effectively be pulling out the peaks. – Alex R. Sep 18 '12 at 17:37