search for: sumprob

Displaying 2 results from an estimated 2 matches for "sumprob".

2007 Jul 20
1
Column-mean-values for targeted rows
...simple function in R which should not be very efficient indeed! It works well for current-dimension matrices, but it just not goes so well in huge ones. meanprob<-function(Robj){ NLINE<-dim(Robj)[1]; NCOLUMN<-dim(Robj)[2]; mprob<-c(rep(0,(NCOLUMN-1))); for (i in 2:NCOLUMN){ sumprob<-0; pa<-0; for (j in 1:NLINE){ if(Robj[j,1]!=0){ pa<-pa+1; sumprob<-Robj[j,i]+sumprob; } } mprob[i-1]<-sumprob/pa; } return(mprob); } So I "only" see 3 ways to get through the problem: - to reform...
2011 Oct 02
2
Sum of Probabilities in a matrix...
Hi all, I have 2 columns in a mtrix, one of which is a column of probabilities and the other is simply a vector of integers. I want to sum all the probabilities with the same integer value and put it in a new column. For example, If my matrix is: 0.98 2 0.2 1 0.01 2 0.5 1 0.6 6 Then I should get: 0.98 2 0.99 0.2 1 0.70 0.01 2 0.99 0.5 1 0.70 0.6 6