# measure distance between peaks in a pdf

I'm looking for a measure/score for the following case:

I have a 1D vector of size s. The vector has values (probabilities) in several places, whilst most of the vector is zeros. I need some kind of score/measure that takes into account the distances between the non-zero values, for example: s = 16, vec1 = [0.2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.44]; vec2 = [0 0 0 0 0 0.2 0.44 0 0 0 0 0 0 0 0 0]; I want vec1 "score" to take into account that these probabilities are far, other then in vec2. In the next step, I would also like to consider the probability itself in this score, i.e. if non-zero values are very far but very similar the measure should give a lower result than if they were very different.

Thank you,

-

Give each bin in the vector an $x$ position and then calculate the standard deviation of the distribution. This will give you a measure of how "spread out" your distribution is. For example, if you have: $$a = [0,0,0.3,0.7,0,0,0],\ \ b = [0.5,0,0,0.1,0,0,0.4]$$ Assign: $$x = [-3,-2,-1,0,+1,+2,+3]$$ And calculate the variance: $$var(a)=\sum a_ix_i^2 = 0.3$$ $$var(b)=\sum b_ix_i^2 = 8.1$$
@matlabit - you misunderstand me. I mean that you can calculate the std in $x$. I'll clarify my answer. – nbubis Jan 28 '13 at 19:55
If $x$ isn't symmetric, you'll need to use the full formula for the variance which can be found on the wikipedia page. Also, if you like an answer - you can upvote it as well. – nbubis Jan 29 '13 at 17:57