|Class:||TVector, TIntVector |
|Declaration:||procedure MeanVar (LowElem, HighElem: integer; var Mean, Variance: double); |
The method MeanVar calculates the mean and the variance of the vector elements within a specified range. The range of the vector elements which are used for the calculation is determined by the parameters LowElem and HighElem. If any of these parameters receives an invalid value, this value is automatically adjusted to nearest boundary value (either 1 or NrOfElem). Note, that in the case of the method MeanVar the vector is not considered as a vector in its usual sense but merely as a collection of numbers.
The variable parameters Mean and Variance return the mean and the variance of the selected data.
||If there are less than three elements within the specified range of the vector the calculation of the variance is impossible. In this case a value of 1.0 is assigned to the variable Variance.
||The function MeanVar 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 =
||The statement Vec1.MeanVar (1,20,Mean,Vari); calculates the mean and the variance for the vector elements 1...20 and returns them in the variables Mean and Vari.