The function ClassScatterMatrices calculates the betweenclass and withinclass scatter matrices. The parameter InData contains the data to be analyzed (rows are objects, columns are variables) and the parameter ClassVec contains the corresponding class numbers.
On return, the variable parameter NClasses contains the number of found classes. The variable arrays ClCnt, ClMeans and ClVars contain the number of members of each class, the class means and the class variances, respectively. The first index of the arrays ClMeans and ClVars designates the corresponding variable, the second index addresses the class number (zerobased indices!). For example, the element ClVars[3,0] contains the variance of the fourth variable for the first class.
The scatter matrices S_{b} and S_{w} are calculated according to the following equations. Please note that the scatter matrices are not scaled to the number of data points (which is sometimes the case in other implementations):
with
C ... number of classes
N_{c} ... number of data points per class
m ... overall mean
m_{c} ... mean of the class c
x_{n} ... data points
s_{c} ... first index of the class c (assuming the dataset is ordered according to the class numbers)
t_{c} ... last index of the class c
The function returns the following error codes:
0 ... everything is OK
1 ... lengths of InData and ClassVec do not match
2 ... the class vector contains invalid class numbers
3 ... the class vector does not contain contiguous class numbers
