search for: tarray

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

Did you mean: array
2006 Jul 17
1
multiplying multidimensional arrays (was: Re: [R] Manipulation involving arrays)
...solution below posted on r-help could have been a bit slicker if %*% worked with multidimensional arrays multiplying them so that if the first arg is a multidimensional array it is mulitplied along the last dimension (and first dimension for the second arg). Then one could have written: Tbar <- tarray %*% t(wt) / rep(wti, each = 9) which is a bit nicer than what had to be done, see below, given that %*% only works with matrices. I suggest that %*% be so extended to multidimensional arrays. Note that this is upwardly compatible and all existing cases would continue to work unchanged. On 7/16/...
2006 Jul 16
1
Manipulation involving arrays
...lt;- 120 sigerr <- 5 covmat <- diag(c(8,6,3.5)) mu <- c(105,12,10) mcsamp <- 10000 Tbar <- array(0, dim=c(3,3,n)) # theta is a mcsamp x 3 matrix theta <- mvrnorm(mcsamp, mu = mu, Sigma = covmat) wt <- matrix(runif(n*mcsamp),n,mcsamp) wti <- apply(wt,1,sum) tarray <- array(apply(theta,1,function(x)outer(x,x)),dim=c(3,3,mcsamp)) for (i in 1:n) { for (k in 1:mcsamp) { Tbar[,,i] <- Tbar[,,i] + wt[i,k] * tarray[,,k] } Tbar[,,i] <- Tbar[,,i] / wti[i] } ############################################### Thanks very much, Ravi.