Skip to content

Average of Two Matrices

2 messages · T.D. Rudolph, Joshua Wiley

#
Well, you're rather stuck writing them all out unless you have them in
some other data structure.

## three dimensional array (50 4 x 4 matrices)
x <- array(rnorm(16 * 50), dim = c(4, 4, 50))
[,1]        [,2]         [,3]        [,4]
[1,] -0.09460574  0.01572077 -0.166194625 -0.28176540
[2,] -0.26649044 -0.23546332 -0.003559647 -0.09857819
[3,]  0.12657883  0.10979631  0.368414189 -0.13653997
[4,] -0.02827496  0.07634844 -0.088057890  0.06208034
## list of length 50 each element is 4 x 4 matrix
[1] 50
[,1]        [,2]        [,3]       [,4]
[1,] -1.8334660  0.67812999  0.20159314  1.6163501
[2,] -0.6716821 -0.23942474 -0.50482638 -0.5765309
[3,]  0.7991496  0.38674047 -0.02128386 -1.1868209
[4,] -1.1654429  0.06773386  0.13538268  0.3847375

See ?array ?apply ?Reduce for documentation

Hope this helps,

Josh
On Wed, Nov 30, 2011 at 7:22 PM, T.D. Rudolph <tylerdrudolph at gmail.com> wrote: