2.1.24.4.20 ocmath_d_mean_variance


Description

calculate mean and variance, and also supports missing value.

Syntax

double ocmath_d_mean_variance( const double * pData, UINT nSize, double * prVariance, UINT * pnActualSampleSize = NULL )

Parameters

pData
[input] buffer containing data
nSize
[input] size of pData
prVariance
[output] return Variance of pData.
pnActualSampleSize
[output] actual sample size(actual data number in pData)

Return

mean

Examples

EX1

void ocmath_d_mean_variance_ex1()
{
    Worksheet wks = Project.ActiveLayer();
    wks.SetSize(-1,2);
    DataRange dr;
    dr.Add("X", wks, 0, 0, -1, 0);
    dr.Add("Y", wks, 0, 1, -1, 1);
    
    vector vxData, vyData;
    DWORD dwPlotID;
    if(dr.GetData(DRR_GET_MISSING | DRR_GET_DEPENDENT | DRR_NO_FACTORS, 0, &dwPlotID, NULL, &vyData, &vxData) < 0)
    {
            printf("get data failed!");
            return;
    }
    
    uint     nSize = vyData.GetSize();
    double     dVariance;
    uint     nActualSampleSize;
    double     dMean = ocmath_d_mean_variance(vyData, nSize, &dVariance, &nActualSampleSize);
}

Remark

Data types supported:

double: ocmath_d_mean_variance
float: ocmath_f_mean_variance
unsigned short: ocmath_us_mean_variance
unsigned char: ocmath_b_mean_variance

See Also

ocmath_us_mean_variance, ocmath_b_mean_variance, ocmath_f_mean_variance

Header to Include

origin.h

Reference