2.1.17.7.1 MatrixBasicStats
Description
This function will give the summary of the statistics of a source data contained in a matrix.
If data does not have the weight, then the default weight 1 will be used
Syntax
int MatrixBasicStats( matrix & mData, MatrixStats & sMatStatsSum, matrix * mpWeights = NULL )
Parameters
- mData
- [input]The Data Source
- sMatStatsSum
- [output]The Results
- mpWeights
- [input]The pointer to a weight matrix if any
Return
Returns 0 on successful exit
MAT_ERR_WEIGHTS_DATA_SIZE_NOT_MATCH: The weight matrix sizes do not match those of the source
Examples
EX1
int Matrix_MatrixBasicStats_ex1()
{
MatrixStats sMatStatsSum;
matrix mData = {{193.0, 215.0, 112.0, 161.0}, {92.0, 140.0, 38.0, 33.3}, {279.0,
249.0, 473.0, 339.0}, {60.0, 130.0, 20.0, 50.0}, {257.0, 284.0,
447.0, 52.0}, {67.0, 61.0, 150.0, 2220.0}};
matrix mWeights;
int nNumCols = mData.GetNumCols();
int nNumRows = mData.GetNumRows();
mWeights.SetSize(nNumRows, nNumCols);
mWeights = 1;
int nRet;
if(nRet = MatrixBasicStats(mData, sMatStatsSum, &mWeights))
return nRet;
printf("Number of cases is %d\n", sMatStatsSum.nMissingValue);
printf("And there is no weight\n");
printf("The input is following : x=\n");
for(int ii = 0; ii < nNumRows; ii++)
{
for(int jj = 0; jj < nNumCols; jj++)
printf("%10.1f", mData[ii][jj]);
printf("\n");
}
printf("\nsucess is%d\n", nRet);
if(nRet == 0)
{
printf("\nsucessfully call of the MatrixBasicStats function\n");
printf("the output is following:\n");
printf("No of missing cases %10d\n", sMatStatsSum.nMissingValue);
printf("mean %10.1f\n", sMatStatsSum.dMean);
printf("std devn %10.1f\n", sMatStatsSum.dSD);
printf("Minimun %10.1f\n", sMatStatsSum.dMin);
printf("Maximum %10.1f\n", sMatStatsSum.dMax);
printf("Sum of weights %10.1f\n", sMatStatsSum.dWSum);
}
else
{
printf(" \n There are some problems.");
}
return nRet;
}
Remark
See Also
Header to Include
origin.h
Reference
|