MeanVarMatrix

Declaration: MeanVarMatrix (Data: TDouble2DArray; FirstCol, FirstRow, LastCol, LastRow: integer; var Mean, Variance: double): integer;
Calculates the mean and the variance of the data contained in the two-dimensional array Data, using all values in the rectangular region defined by [FirstCol,FirstRow] and [LastCol,LastRow] (the array Data has 0-based indices). If FirstCol or FirstRow is greater than LastCol or LastRow the parameters are automatically exchanged.

The function returns the following error codes:

 0 ... everything is OK
-1 ... FirstCol, FirstRow, LastCol and/or LastRow are out of range
-2 ... the number of values is too low (minimum of 3 values required)