2.1.24.4.38 ocmath_quantiles
Description
Function to compute quantiles including Min, iMin, Max, iMax, Range and IQR for a vector.
Syntax
int ocmath_quantiles( const double * pData, UINT nSize, const QuantileOptions * opt, QuantileResults * res, const double * pPercents = NULL, UINT nPercentSize = 0, double * pPercentiles = NULL, const double * pWeight = NULL )
Parameters
- pData
- [input] pointer to data on which quantiles are computed
- nSize
- [input] value indicates the size of pData
- opt
- [input] pointer to structure of quantile options
- res
- [output] pointer to structure containing quantile results
- pPercents
- [input] Optional input pointer to custom percents for which percentiles are computed
- nPercentSize
- [input] Optional, size of pPercents
- pPercentiles
- [output] Optional output vector containing custom percentiles (results)
- pWeight
- [input] Optional input pointer to weights.
Return
Returns STATS_NO_ERROR on successful exit and a non-zero STATS error code on failure.
Examples
EX1
void ocmath_quantiles_ex1()
{
vector vData = { 1.1, 0.1, 2.2, 4.3, -4.2, 5.2, 1.6, 7.2, 0.8, 3.5 };
int nSize = vData.GetSize();
QuantileOptions opt;
QuantileResults res;
vector pPercents;
vector pPercentiles;
int nRet;
opt.Min = true;
opt.iMin = true;
opt.Q1 = true;
opt.Median = true;
opt.Q3 = true;
opt.Max = true;
opt.iMax = true;
opt.IQR = true;
opt.Range = true;
int nPercentSize = 4;
pPercents.SetSize(nPercentSize);
pPercents[0] = 78;
pPercents[1] = 41;
pPercents[2] = 21;
pPercents[3] = 6;
opt.Interpolate = INTERPOLATE_WEIGHT_AVER_RIGHT;
nRet = ocmath_quantiles(vData, nSize, &opt, &res, pPercents, nPercentSize, pPercentiles);
}
Remark
See Also
Header to Included
origin.h
Reference
|