[R] more efficient double sum computation ...

kathie kathryn.lord2000 at gmail.com
Fri Aug 29 06:28:56 CEST 2008


Dear R users...

I made the R-code for this double summation computation
http://www.nabble.com/file/p19213463/doublesum.jpg 


-------------------------------------------------
Here is my code..


sum(sapply(1:m, function(k){sum(sapply(1:m,
function(j){x[k]*x[j]*dnorm((mu[j]+mu[k])/sqrt(sig[k]+sig[j]))/sqrt(sig[k]+sig[j])}))}))


-------------------------------------------------

In fact, this is a part of optimization. I think if it is changed more
efficiently, then the running time could be reduced.

How could I change this to more efficient one? Any suggestion will be
greatly appreciated.

Kathryn Lord



-- 
View this message in context: http://www.nabble.com/more-efficient-double-sum-computation-...-tp19213463p19213463.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list