# Standard deviation between layers of a 3DWave

Jakub

Fri, 05/15/2020 - 08:07 am

Hi,

I am using a sumbeams function of the MatrixOP to get the matrix of average values across the 3D wave. I simply sum them using the aforementioned function and divide the resulting sum by the number of layers. Now, additionally to the average values, I also need a standard deviation. Is there a way to obtain it across layers of a 3D wave for each element of each matrix? Can I subject each element in each matrix to an expression like SQRT(Variance)?

Thank you for help.

JB

If I understand your goal correctly and if speed is not a crucial issue, it seems you could you use WaveStats/RMD[row][col][] and iterate over all rows and columns, providing you with count, average, standard deviation for each beam, which you would then have to store during the loop.

It also seems like you could reorient the data so that you can use Wavestats/PCST, like so:

make/o/d/n=(10,20,30) whatever = enoise(1) //an example multidimensional wave for which stats for each beam are desired

imagetransform/g=3 transposevol whatever //swap the layers into the rows so /PCST can run on each column (and what had been each row)

wavestats/pcst M_VolumeTranspose //get statistics for each column, each layer is treated separately

imagetransform/g=3 transposevol M_wavestats //swap the rows (statistics) back into the layers, so the original and row and column positions are restored.

//M_VolumeTranspose contains the results

copydimlabels/rows=2 M_wavestats,M_VolumeTranspose //copy statistics dimension labels

//in case original wave had dimension labels:

copydimlabels/rows=0 whatever,M_VolumeTranspose //copy row labels to results wave

copydimlabels/cols=1 whatever,M_VolumeTranspose //copy col labels to results wave

//averages are stored in layer 3 and standard deviations in layer 4, so this provides each for all rows and columns:

duplicate/o/r=[][][finddimlabel(M_VolumeTranspose,2,"avg")] M_VolumeTranspose, results_avg

duplicate/o/r=[][][finddimlabel(M_VolumeTranspose,2,"sdev")] M_VolumeTranspose, results_sdev

There are, perhaps, faster implementations with matrixop, but if you decide you want yet another statistic in the future, that statistic might already be accessible with this approach.

May 15, 2020 at 08:59 am - Permalink

The approach outlined above is indeed very elegant. It is however not clear to me what the OP meant by:

(a) "Is there a way to obtain it across layers of a 3D wave for each element of each matrix?"

and

(b) "subject each element in each matrix to an expression like SQRT(Variance)?"

It is important to specify which variance the OP needs to calculate. Since a variance calculation requires the subtraction of a mean, it is important to specify which mean is being calculated (e.g., mean of a column, mean of a layer or of a beam). Note that in the special case of zero mean you can factor out the (1/(n-1)) from the variance and simply add the contributions from various columns, layers, etc.

May 15, 2020 at 10:52 am - Permalink

In reply to The approach outlined above… by Igor

Indeed, I don't need speed in this case and I thank for the solution. I just thought there exists an equivalent of "sumbeams" parameter to obtain standard deviation.I presume it should be across beams. If I understand the idea of a beam correctly, it's a higher dimension, column-like structure going across the wave layers. I need stdev of beams.Same as above. I need standard deviation, or the square root of the variance, which is the same thing, isn't it?May 27, 2020 at 11:13 pm - Permalink

FWIW, I added to IP9 a new MatrixOP function called varBeams(). The method suggested above may be the best solution in IP8.

May 28, 2020 at 08:07 am - Permalink

In reply to FWIW, I added to IP9 a new… by Igor

Why not in 8beta? I've just recently upgraded to 8...

May 28, 2020 at 01:57 pm - Permalink

This is a new feature and IP8 is not getting any new features at this point.

May 28, 2020 at 02:24 pm - Permalink

Looks like very short life cycle...Will my IP8 licence compatible with IP9?

May 29, 2020 at 09:58 am - Permalink

@Jakub: We released Igor 8 more than 2 years ago (May 22, 2018). Your IP8 license won't work with IP9, but we often provide free upgrades to users that purchased a new license or upgrade within some period before a new major version is released. As far as I know we have not yet made a decision on whether we will do that for IP9 and if so what the cutoff date will be. The IP9 beta is taking longer to put together than we had expected and the pandemic isn't helping.

May 29, 2020 at 10:35 am - Permalink