2.1.24.4.5 ocmath_2d_binning_stats


Description

Compute descriptive statistics for 2D binning on two arrays pX and pY.

Syntax

int ocmath_2d_binning_stats(int nSize, const double *pX, const double *pY, BinningStatsResult* pResult, int nStats, BinningOption* pOptionX = NULL, BinningOption* pOptionY = NULL)

Parameters

nSize
[input]size of the X and Y array
pX
[input]pointer to buffer of the X array data
pY
[input]pointer to buffer of the Y array data
pResult
[output]pointer to result structure
nStats
[input]One of the following:
enum{
	OCMATH_2D_BINNING_MIN,
	OCMATH_2D_BINNING_MAX,
	OCMATH_2D_BINNING_MEAN,
	OCMATH_2D_BINNING_SUM,
	OCMATH_2D_BINNING_MEDIAN,
	OCMATH_2D_BINNING_PERCENTAGES,
};
pOptionX
[input]pointer to the structure of BinningOption for X array. If it is NULL(default), the optional parameters are given by the function.
pOptionY
[input]pointer to the structure of BinningOption for Y array. If it is NULL(default), the optional parameters are given by the function.
typedef struct
{
   double    dMin;    // the minimum of the range
   double    dMax;    // the maximum of the range
   double    dInc;    // the bin increment of the range
   int	     wIncludeOutliers;    // flag indicating whether or not to include outliers in first and last bins, values are defined in enum FrequncyAccounOutBin, default value is FAB_NOT_INCLUDE_OUTLIERS
   double    dPeriod;  //period for the data		
   int       wIncludeMinMax; // reuse flag in wIncludeOutliers, left for Min, right for Max
   int	     nMode;    // BIN_MODE_INC, BIN_MODE_VALS
   double*   pdVals;   // Double Array for BIN_MODE_VALS, for example, fill with 3 7 12 20, min=0, max=30, then the bins should be 0-3, 3-7, 7-12, 12-20, 20-30, >=30
   int	     nValsSize;// The size of pdVals
}BinningOption;

Return

Returns 0 on success. Otherwise returns error code:

-1: Empty pointer or invalid value for nStats.

BINNING_ERR_SIZE: nSize less than 1

BINNING_ERR_RANGE: range is invalid(dMin > dMax)

BINNING_ERR_INC: dInc <= 0 or dInc > dMax - dMin

BINNING_ERR_FLAG: wIncludeOutliers is not defined in the enum

BINNING_ERR_PERIOD: error period.

BINNING_ERR_BUFFER_TOO_SMALL: size of pResult->pMatrix is less than needed

Examples

Remark

This function does not output frequency count, it calculates multiple statistics quantities on each bin according to input variable nStats, for example, minimum, maximum, median etc.

See Also

ocmath_2d_binning

Header to Include

origin.h

Reference