2.1.24.4.19 ocmath_d_frequency_count


Description

Frequency Count for type double.

Syntax

int ocmath_d_frequency_count( double * pSource, uint nSourceSize, uint * pDest, uint nDestSize, double dbBinBegin, double dbBinIncrement )

Parameters

pSource
[input] buffer containing data to be counted
nSourceSize
[input] size of pSource
pDest
[output] buffer of count results
nDestSize
[input] size of pDest
dbBinBegin
[input] first bin's left edge
dbBinIncrement
[input] width of each bins

Return

Returns OE_NOERROR(0) on success.

Examples

EX1

// Uses the active worksheet. Put data into column 1, result goes into column 2 (the bin centers) and column 3 (the counts)
void ocmath_d_frequency_count_Ex1()
{
    Worksheet wks = Project.ActiveLayer();
    wks.SetSize(-1,3);
    DataRange drIn;
    drIn.Add("X", wks, 0, 0, -1, 0);
    vector vecData;
    drIn.GetData(&vecData, 0);
    vector<uint> vecFCount;
    //BIN_RULE_STURGES
    int nBinsApproximate = 1.5 + log(vecData.GetSize())/log(2);
    double min, max, binW;
    vecData.GetMinMax(min, max);
    int nNumBins = RoundLimits(&min, &max, &binW, nBinsApproximate);    
    vecFCount.SetSize(nNumBins);
    bool bRet = ocmath_d_frequency_count(vecData, vecData.GetSize(), vecFCount, vecFCount.GetSize(), min, binW);
    DataRange drOut;
    drOut.Add("X", wks, 0, 1, -1, 1);
    drOut.Add("Y", wks, 0, 2, -1, 2);
    vector binCenter;
    binCenter.Data(min+binW/2, max-binW/2, binW); // Calculate bin center data
    drOut.SetData(&vecFCount, &binCenter);
}

Remark

Count the frequency from dbBinBegin to dbBinIncrement* nDestSize ([dbBinBegin, dbBinIncrement* nDestSize))with dbBinIncrement as interval.

See Also

vectorbase::FrequencyCount, ocmath_f_frequency_count, ocmath_us_frequency_count, ocmath_b_frequency_count

Header to Include

origin.h

Reference