/*------------------------------------------------------------------------------* * File Name: ComputeStatsOnRows.c * * Creation: ER, 01/17/05 * * Purpose: Programming Example * * Copyright (c) OriginLab Corp.2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 * * All Rights Reserved * * * * Modification Log: * *------------------------------------------------------------------------------*/ #include ///////////////////////////////////////////////////////////////////////////////// // This example shows how to get part of a dataset and then compute statistics on // rows with the data // // NOTE: It is assumed that a worksheet with data is active. // void coompute_stats_on_rows() { // Declare worksheet and check validity Worksheet wks = Project.ActiveLayer(); if( !wks ) return; // Construct data range rows from 5 to 10 for all columns DataRange dr; int r1 = 4, c1 = 0, r2 = 9, c2 = -1; dr.Add("X", wks, r1, c1, r2, c2); // Range name shoule be make sense, like X, Y, Z // Get data from the specified rows matrix mData; DWORD dwRules = DRR_BY_ROWS | DRR_GET_MISSING | DRR_NO_FACTORS | DRR_NO_WEIGHTS; int nDataIndex = 0; int nn = dr.GetData(dwRules, nDataIndex, NULL, NULL, NULL, NULL, &mData); if(nn < 0) { out_str("Failed to GetData from data range"); return; } // Compute statistics on rows for the data in mData double dMean, dSD, dSem, dLCL, dUCL, dVariance, dSDx2; if(OE_NOERROR == ocmath_row_desc_stats_ex(mData.GetNumRows(), mData.GetNumCols(), mData, &dMean, &dSD, &dSem, NULL, NULL, NULL, NULL, &dLCL, &dUCL, &dVariance, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &dSDx2) ) { printf("Mean = %lf\n", dMean); printf("SD = %lf\n", dSD); printf("Sem = %lf\n", dSem); printf("LCL = %lf\n", dLCL); printf("UCL = %lf\n", dUCL); printf("Variance = %lf\n", dVariance); printf("SDx2 = %lf\n", dSDx2); } } /////////////////////////////////////////////////////////////////////////////////