ocmath_opt_summary_stats

Description

Function to compute descriptive statistics other than basic ones from raw data, like Mode, Geometric Standard Deviation, The dConfLevel confidence interval of mean, etc.

Syntax

OCMATH_API int ocmath_opt_summary_stats(UINT nSize, const double *pData, const double dConfLevel, double* pMode = NULL,  bool* pmultimodes = NULL,
double* pGSD = NULL, double* pLCL = NULL, double* pUCL = NULL, double* pSDx2 = NULL,
double* pSDx3 = 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
dConfLevel
[input] Confidence Level
pMode
[output] The mode is the element that appears most often in the data range. If multiple modes are found, the smallest will be chosen.
pmultimodes
[input] Flag indicating whether using multit
pGSD
[output] The geometric standard deviation. Weights are ignored for the geometric standard deviation.
pLCL
[output] Lower limit of the dConfLevel confidence interval of mean
pUCL
[output] Upper limit of the dConfLevel confidence interval of mean
pSDx2
[output]Standard deviation times 2
pSDx3
[output]Standard deviation times 3
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 Mode and Geometric Standard Deviation
ocmath_opt_summary_stats_ex1()
{
vector vData={3,2,1,4,2,5,4,6,9};
int nSize = vData.GetSize();
double dConfLevel = 0.95;
bool bMultiModes = TRUE;
double dMode, dGSD;
int nRet = ocmath_opt_summary_stats(nSize, vData, dConfLevel, &dMode, &bMultiModes, &dGSD);
if(0 == nRet)
{
out_double("Mode = ",dMode);
out_double("GSD = ",dGSD);
}
}


EX2

//This example is to calculate upper and lower limit of the 95% confidence interval of mean
ocmath_opt_summary_stats_ex2()
{
vector vData={3.1,3.2,4.1,4.2,5.4,6.9};
int nSize = vData.GetSize();
double dConfLevel = 0.95;
bool bMultiModes = TRUE;
double dLCL, dUCL;
int nRet = ocmath_opt_summary_stats(nSize, vData, dConfLevel, NULL, &bMultiModes, NULL, &dLCL, &dUCL);
if(0 == nRet)
{
out_double("LCL = ",dLCL);
out_double("UCL = ",dUCL);
}
}


Remark

Function to compute descriptive statistics other than basic ones.