Function to calculate frequency count for discrete/categorical numeric data. Frequency is computed for each non-duplicated value of input data.
int ocmath_discrete_frequencies(const double* pSource, const UINT nSourceSize, double* pData, double* pFreqs, int* pnFreqs = NULL)
Returns STATS_NO_ERROR on successful exit and a non-zero STATS error code on failure.
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]); } } }
Ocu_discrete_frequencies, DatasetObject::PercentText
origin.h