2.1.24.4.6 ocmath_basic_summary_stats


Description

Function to compute basic descriptive statistics from raw data, like Total Number, Mean, Standard Deviation, Skewness, etc.

Syntax

OCMATH_API int ocmath_basic_summary_stats(UINT nSize, const double *pData, int* pN, double* pMean, double* pSD = NULL, double* pSE = NULL, 
					double* pVariance = NULL,  double* pSum = NULL, double* pSkewness = NULL, double* pKurtosis = NULL, 
					double* pUSS = NULL, double* pCSS = NULL, double* pCOV = NULL, double* pMAD = NULL, int* pMissing = NULL, 
					double* pWeightSum = NULL, double* pGMean = NULL, int MomentDenFlag = DS_SAS1_DOF, const double *pWt = NULL)

Parameters

nSize
[input] Size of raw data array
pData
[input] Pointer to raw data array
pN
[output] Total number of data points, denoted by n
pMean
[output] The mean (average )score
pSD
[output] Standard deviation
pSE
[output] Standard error of mean
pVariance
[output] Variance
pSum
[output] Sum of pData with Weight
pSkewness
[output] Skewness. Skewness measures the degree of asymmetry of a distribution.
pKurtosis
[output] Kurtosis. Kurtosis depicts the degree of peakedness of a distribution.
pUSS
[output] Uncorrected Sum of Squares
pCSS
[output] Corrected Sum of Squares
pCOV
[output] Coefficient of Variance
pMAD
[output] Mean Absolute Deviation
pMissing
[output] Number of missing values
pWeightSum
[output] Sum of Weights
pGMean
[output] Geometric Mean. Weights are ignored for the geometric mean
MomentDenFlag
[input] Variance Divisor of Moment. This option decides the method to compute variance divisor d. You can use one of the following options: DS_SAS1_DOF, DS_SAS2_N, DS_SAS3_WDF, DS_SAS4_WGT and DS_NAG. They will compute d as degree of freedom, number of non-missing observations, degree of Sum of weights, sum of weights and WVR, respectively
pWt
[input] Pointer to Weights


Return

Return STATS_NO_ERROR (0) on success. Otherwise returns error.

Examples

EX1

//This example is to calculate the Total number, Mean and Standard Deviation.
void ocmath_basic_summary_stats_ex1()
{
	vector vData={3,2,1,4,2,5,4,6,9};
	int nSize = vData.GetSize();
	int nN;
	double dMean, dSD;
	int nRet = ocmath_basic_summary_stats(nSize, vData, &nN, &dMean, &dSD);
	if(0 == nRet)
	{
		out_double("Mean = ",dMean);
		out_double("SD = ",dSD);
	}
}

EX2

//This example is to calculate Skewness and Kurtosis.
void ocmath_basic_summary_stats_ex2()
{
	vector vData={3.1,3.2,4.1,4.2,5.4,6.9};
	int nSize = vData.GetSize();
	double dSkewness, dKurtosis;
	int nRet = ocmath_basic_summary_stats(nSize, vData, NULL, NULL , NULL, NULL , NULL, NULL , &dSkewness, &dKurtosis);
	if(0 == nRet)
	{
		out_double("Skewness = ",dSkewness);
		out_double("Kurtosis = ",dKurtosis);
	}
}

Remark

Function to compute basic descriptive statistics.

See Also

ocmath_opt_summary_stats

Header to Include

origin.h

Reference