DataLab is a compact statistics package aiming at exploratory data analysis. Please visit the DataLab Web site for more information....

## MeanVarOfMarkedCells

 Declaration: TDataTable.MeanVarOfMarkedCells (LowCol, LowRow, HighCol, HighRow: integer; CellState: byte; var Mean, Variance: double): integer; The method MeanVarOfMarkedCells calculates the mean and the variance of all matrix elements within a specified range of cells which meet the following requirements: (1) they are not marked as csNAN, nor as csUndefined, (2) their cell state has to match the CellState parameter at least in one bit, and (3) they have to belong to either interval or ratio scaled variables (that is "real" numbers). Allowed states of the CellState parameter are csReadOnly, csImputed, csMarkedA, and csMarkedB. The range of matrix elements to be used is determined by the parameters LowRow, LowCol, HighRow, and HighCol. If any of these parameters receives an invalid value, this value is automatically adjusted to the nearest boundary value (either 1 or NrOfColumns / NrOfRows). The variable parameters Mean and Variance return the mean value and the variance of the selected data. The function returns the number of data points used for the calculation (i.e. the number of marked numeric data cells within the specified range).

 Hint 1: If there are less than three values within the specified range of the matrix, the calculation of the variance is impossible. In this case a value of 1.0 is assigned to the variable Variance.

 Hint 2: Setting both the low and high parameter of a dimension (i.e. LowCol and HighCol) to zero values forces the method to use all elements of that dimension.

 Hint 3: The function MeanVarOfMarkedCells assumes that the values used for the calculation of the variance are sample data. If you have to calculate the variance of a population (i.e. all values ever measured) you have to multiply the variance by a factor of  n/(n-1), with n being the number of values used for the calculation: n = (HighRow-LowRow+1)*(HighCol-LowCol+1).