get input matrix's each row's mean, standard deviation, se of mean, min, max, sum and total number of data point and put result to relative pointer if the pointer not NULL.
int ocmath_row_desc_stats( UINT nRows, UINT nCols, const double * pMat, double * pMean = NULL, double * pSd = NULL, double * pSem = NULL, double * pMin = NULL, double * pMax = NULL, double * pSum = NULL, double * pN = NULL, double * pLCL = NULL, double * pUCL = NULL, int nMomentDenFlag = DS_SAS1_DOF )
Return OE_NOERROR(0) if succeed, otherwise, non-zero error code is returned:
OE_RANGE_ZERO(-3): nRows < 1 or nCols < 1
OE_NULL_POINTER(-11): pMat is NULL
OE_ALLOC_FAIL(-19): allocate internal used memory failed
EX1
/* Usage from LT: 1. rr(1,2); // col(1) to col(2) 2. rr(1,0); // all columns, use 0 for nC2 to indicate last column */ bool rr(int nC1, int nC2) { Worksheet wks = Project.ActiveLayer(); if( !wks ) { out_str("Please keep a worksheet active with data"); return false; } nC1--; //convert from LT index to OC index if(nC2 <= 0) nC2 = -1;//indicate all cols else nC2--; DataRange dr; string strRangeName = "X"; dr.Add(wks, nC1, "X", nC2);//construct a data range object from worksheet matrix mData; dr.GetData(mData); // get data from range object int nRows = mData.GetNumRows(); int nCols = mData.GetNumCols(); if( nRows <= 0 || nCols <= 0 ) { out_str("Please make sure input argument r1, c1, r2, c2 all are correct."); return false; } vector vMean(nRows); vector vSd(nRows); int nRet = ocmath_row_desc_stats(nRows, nCols, mData, vMean, vSd); if( OE_NOERROR != nRet ) { printf("Error: ocmath_row_desc_stats returns %d\nPlease press F1 to open Origin C help to see more details about this function.\n", nRet); return false; } int nMean = wks.AddCol("Mean"); int nSD = wks.AddCol("SD"); DataRange drOutput; drOutput.Add(wks, nMean, "X"); drOutput.SetData(vMean, false, 0); drOutput.Add(wks, nSD, "X"); drOutput.SetData(vSd, false, 1); return true; }
ocmath_row_quantiles, ocmath_basic_summary_stats
origin.h