2 Jul 15:25
Creating a Matrix from a Sum
Lorenzo Isella <lorenzo.isella <at> gmail.com>
2009-07-02 13:25:42 GMT
2009-07-02 13:25:42 GMT
Dear All,
I need some help to efficiently write an array manipulation. I suspect
this could be a one-liner.
Assume that you have a histogram of observations that you store in a
vector x.
Let us say that its i-th entry, x_i, corresponds to the number of
observations in the i-th channel, for i=1,2...N. (or 0,1...N-1, please
let me know if there is any potential 0/1 pitfall in the following).
Now, for any two channels i and j, I want to calculate the probability
of having an observation in any other channel k, where k>=max(i,j).
That is to say
P(i,j)=sum_{k=max(i,j)}^N x_k /C,
where C=sum_{i=1}^N x_i is just a normalization factor.
Does anyone know a good way of writing this in a code to get the P(i,j)
matrix?
Many thanks
Lorenzo
RSS Feed