Computing variance per element after averaging matrices

I have several different 8X8 matrices and I would like to compute the average value per element for 64 elements. In addition I would like to compute statistics such as st.deviation in each element. I am planning on using MatrixOP to sum up the matrices and divide by the total number to get a per element average but can't see a way to calculate variance on a per element basis and I would appreciate some help with this.
I would approach this by stacking your 8x8 matrices into a 3d wave using Concatenate. Then you have several ways to do what you want. For example, write a loop to use MatrixOp beam to get a 1D wave corresponding to each m,n location and run wavestats. In fact, using the /RMD flag you can probably just compute what you need without extracting the beam.
sjr51 wrote:
I would approach this by stacking your 8x8 matrices into a 3d wave using Concatenate. Then you have several ways to do what you want. For example, write a loop to use MatrixOp beam to get a 1D wave corresponding to each m,n location and run wavestats. In fact, using the /RMD flag you can probably just compute what you need without extracting the beam.


This is correct but you have to think about the efficiency of the code. If you extract the beams or if you run WaveStats with /RMD you have to iterate over the 8x8 cells. Another way of getting all the results without a loop is to convert your data from 3D to 2D and then execute MatrixOP with varCols(). Suppose your 3D Wave (say srcWave) has dimensions of (8,8,M). In that case you would first execute:
MatrixOP/O aa=transposeVol(srcWave,4)

This should give you an (M,8,8) wave. Next you redimension this into an (M,64) wave:
Redimension/O/N=(M,64)/E=1 aa

and finally you obtain the variance:
MatrixOP/O theVar=varCols(aa)
Clearly, if you wish, you can reshape the results into an 8x8 wave.

I hope this helps,

A.G.
WaveMetrics, Inc.