On Fri, 29 Aug 2008, Giovanni Petris wrote:
You can cut execution time by a factor 2 simply using the fact that the
double summation is symmetric in the indices j and k:
2 * sum(sapply(1:(m-1), function(k){sum(sapply((k-1):m,
function(j){x[k]*x[j]*dnorm((mu[j]+mu[k])/sqrt(sig[k]+sig[j]))/sqr
You can cut execution time by a factor 2 simply using the fact that the
double summation is symmetric in the indices j and k:
2 * sum(sapply(1:(m-1), function(k){sum(sapply((k-1):m,
function(j){x[k]*x[j]*dnorm((mu[j]+mu[k])/sqrt(sig[k]+sig[j]))/sqrt(sig[k]+sig[j])}))}))
+ sum(x^2*dnorm((2*mu
Dear R users...
I made the R-code for this double summation computation
http://www.nabble.com/file/p19213599/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]+si
3 matches
Mail list logo