ocmath_f_frequency_count

 

Description

Frequency Count for type float.

Syntax

int ocmath_f_frequency_count( float * pSource, UINT nSourceSize, UINT * pDest, UINT nDestSize, float dbBinBegin, float 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

void ocmath_f_frequency_count_Ex1()
{
    vector<float> vecData = {0.5, 1, 2, 3, 4, 5};
    vector<uint> vecFCount;    
    uint i1 = 0;
    uint i2 = vecData.GetSize()-1;
    uint min;          //the index for min value in vecData
    uint max;          //the index for max value in vecData
    float binW = 1;     //width of each bin
    int iSize = 5;     //size of vecFCount
    vecFCount.SetSize(iSize);
    uint nMissingValues = ocmath_f_minmax(vecData, i1, i2, NULL, &min, &max);

    int bRet = ocmath_f_frequency_count(vecData, vecData.GetSize(), vecFCount, vecFCount.GetSize(), vecData[min], binW);
    vector binCenter;
    binCenter.Data(vecData[min]+binW/2, vecData[max]-binW/2, binW); // Calculate bin center data
    for (int i = 0; i < iSize; i++)
        {
        printf("%.0f\t",binCenter[i]);
        printf("%d\n",vecFCount[i]);
    
        }
}

Remark

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

See Also

vectorbase::FrequencyCount, ocmath_us_frequency_count, ocmath_b_frequency_count

header to Include

origin.h

Reference