2.1.24.4.16 ocmath_discrete_frequencies


Description

Function to calculate frequency count for discrete/categorical numeric data. Frequency is computed for each non-duplicated value of input data.

Syntax

int ocmath_discrete_frequencies(const double* pSource, const UINT nSourceSize, double* pData, double* pFreqs, int* pnFreqs = NULL)

Parameters

pSource
[Input] pointer to an array containing input data
nSourceSize
[Input] size of an array containing input data
pData
[Output] pointer to a array containing all non-duplucated data in input data. Size of pData is nSourceSize.please note that last (nSourceSize-nFreqs) values are NANUM;
pFreqs
[Output] pointer to an array containing output frequencies corresponding to the pData. Size of pFreqs is nSourceSize.please note that last (nSourceSize-nFreqs) values are NANUM;
pnFreqs
[Output] Optional pointer to number of non-duplicated values in input data.

Return

Returns STATS_NO_ERROR on successful exit and a non-zero STATS error code on failure.

Examples

EX1

#include <ocmath.h>

void Ocmath_discrete_frequencies()
{
	Worksheet wks = Project.ActiveLayer();
	Column colSource(wks, 2);
	if( !colSource )
		return;
	vector vSource = colSource.GetDataObject();


	vector vNoDupData(vSource.GetSize());
	vector vFreq(vSource.GetSize());
	int nFreq;
	if( STATS_NO_ERROR == ocmath_discrete_frequencies(vSource, vSource.GetSize(), vNoDupData, vFreq, &nFreq) )
	{	
		vFreq.SetSize(nFreq);
		for(int nn = 0; nn < nFreq; nn++)
		{
			printf("%g, %g\n", vNoDupData[nn], vFreq[nn]);
		}
	}
}

Remark

See Also

Ocu_discrete_frequencies, DatasetObject::PercentText


Header to Include

origin.h

Reference