| Unit: | SDL_datatable |
| Class: |
TDataTable |
| Declaration: |
function MeanVarOfNumCells (LowCol, LowRow, HighCol, HighRow: integer; var Mean, Variance: double): integer; |
The method MeanVarOfNumCells calculates the mean value and the variance of all matrix elements within a specified range of cells which are neither marked as csNAN, nor as csUndefined (that is "real" numbers). 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 numeric data cells within the specified range).
| Hint 2: |
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 3: |
The function MeanVarOfNumCells 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). |
| Example: |
The statement Mat1.MeanVarOfNumCells (1,2,12,20,Mean,Vari); calculates the mean value and the variance of all matrix elements with the indices [1,2] to [12,20], and returns them in the variables Mean and Vari.
|
|