Check all curves's X value's monotonic and consistent state.
int ocmath_check_order_multiple_curves( UINT nSize, const OneCurveData * pCurves, int nSegments = 3, double * pMeanInc = NULL, double * pSDInc = NULL, int * pSegSize = NULL, double dProb = 0.8 )
if succeed, return MCO_MONO_CONSISTENT if monotonic and consistent,
return MCO_MONO_NOT_CONSISTENT if not monotonic but consistent,
return MCO_NOT_CONSISTENT if curves are not consistent;
orthewise, negetive error code is returned.
EX1
//This example assume the active window is a graph with at least two curves. void ocmath_check_order_multi_curves_ex1() { GraphLayer gl = Project.ActiveLayer(); if (!gl) { return; } int nPlots = gl.DataPlots.Count(); int ii; int nAveSize = 0; OneCurveData* multiCurveData = (OneCurveData*) malloc(sizeof(OneCurveData)*nPlots); double* xx; double* yy; for(ii = 0; ii < nPlots; ii++) { DataPlot dp = gl.DataPlots(ii); DataRange dr; vector vDatax, vDatay; if(dp.GetDataRange(dr)) { DWORD dwPlotID; if(dr.GetData(DRR_GET_DEPENDENT | DRR_NO_FACTORS, 0, &dwPlotID, NULL, &vDatay, &vDatax) < 0) { printf("get_plot_data failed GetData"); return; } } nAveSize = vDatay.GetSize(); xx = (double*) malloc (sizeof(double) * nAveSize); yy = (double*) malloc (sizeof(double) * nAveSize); memcpy(xx, vDatax, sizeof(double)*nAveSize); memcpy(yy, vDatay, sizeof(double)*nAveSize); multiCurveData[ii].nSize = nAveSize; multiCurveData[ii].pX = xx; multiCurveData[ii].pY = yy; } int nSegments = 3; vector vSDInc(nPlots * nSegments); vector<int> vSegSize(nPlots * nSegments); int nRet = ocmath_check_order_multiple_curves(nPlots, multiCurveData, nSegments, vSDInc, NULL, vSegSize); switch(nRet) { case MCO_MONO_CONSISTENT: printf("monotonic and consistent"); break; case MCO_MONO_NOT_CONSISTENT: printf("not monotonic but consistent"); break; case MCO_NOT_CONSISTENT: printf("not consistent"); break; default: printf("failed: error code is %d", nRet); break; } return; }
This function checks all curves's X value are monotonic and consistent, not monotonic
but consistent or not consistent by check each curve use ocmath_check_order_curve.
Number of curves should more than 1. If only one curve, please use ocmath_check_order_curve.
It can handle that the curve has some outliers.
ocmath_check_order_curve, ocmath_check_order
origin.h