Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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,

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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$$

share|improve this answer
    
Hi, std is not what I'm looking for, for example, if v1 = [0.3 ,0,0,0,0,0,0,0,0,0,0,0.56]; and v2 = [0,0,0,0,0,0.3,0.56,0,0,0,0,0]; they both have std= 0.1763 whilst I want v1 measure to be higher then v2 measure, because the peaks are very far. (The values in the vector are very )sparse –  matlabit Jan 28 '13 at 19:15
    
@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
    
Thank you for the clarification, but it is still not what I need I think... I don't want to measure how far my value are distributed from the mean, just from each other, for example, [0.3,0.7,0,0,0,0,0] should have the same score as: [0,0,0,0.3,0.7,0,0], but not as [0.3,0,0,0,0,0,0.7]. it doesn't matter where the values are, I'm interested knowing how spread there are from each other... –  matlabit Jan 29 '13 at 13:13
    
well, I actually think that's ok, I just have one last question, does it matter if x isn't symmetric ? for my needs I need x to be 1:dim? –  matlabit Jan 29 '13 at 17:29
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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