2.1.17.2.12 ocmath_check_order_curve


Description

Test if data is really parametric in nature by divide curve for multiple segments and check each segment.

Syntax

int ocmath_check_order_curve( UINT nSize, const double * pData, int nSegments = 3, double * pMeanInc = NULL, double * pSDInc = NULL, int * pSegSize = NULL, double dProb = 0.8 )

Parameters

nSize
[input] size of pData array.
pData
[input] pointer to curve's X value.
nSegments
[input] number of segments that the curve should be divided, its default value is 3.
pMeanInc
[output] if not NULL, pointer to each segment's X value's mean increment,
its size should be nSegments. its default value= NULL.
pSDInc
[output] if not NULL, pointer to each segment's standard deviation of X
value's increment array, its size should be nSegments. Its default value is NULL.
pSegSize
[output] if not NULL, pointer to each segment's size, its size should be nSegments.
Its default value is NULL.
dProb
[input] detail info please check ocmath_check_order, its default value is 0.8.

Return

if succeed, return MONO_INCREASE if monotonic increase,

return MONO_DECREASE if monotonic decrease,

return MONO_NOT if not monotonic;

orthewise, negetive error code is returned.

Examples

EX1

//This example assume the active window is a graph with one curve.
void ocmath_check_order_curve_ex1()
{
    GraphLayer gl = Project.ActiveLayer();
    if (!gl)
    {
        return;
    }

    DataPlot dp = gl.DataPlots(0);        
    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;
        }
    }

    int nSegments = 3;
    vector vMeanInc(nSegments);
    vector<int> vSegSize(nSegments);
    int nRet = ocmath_check_order_curve(vDatax.GetSize(), vDatax, nSegments, vMeanInc, NULL, vSegSize);
    switch(nRet)
    {
    case MONO_INCREASE:
        printf("monotonic increase");
        break;
    case MONO_DECREASE:
        printf("monotonic decrease");
        break;
    case MONO_NOT:
        printf("not monotonic");
        break;
    default:
        printf("failed: error code is %d", nRet);
        break;
    }
    return; 
}

Remark

Often the curve's X values are really meant to be monotonic, but there are

some outliers that make it look like not. This function tests if data is really

parametric in nature by divide curve for nSegments segments and check each

segment by ocmath_check_order, and nSegments can equal to 1.

See Also

ocmath_check_order_multiple_curves, ocmath_check_order

Header to Include

origin.h

Reference