| ocmath_row_ttest2  DescriptionFunction to perform two-sample t-test for each row. Syntax
int ocmath_row_ttest2( UINT nRows, UINT nCols, const double * pMat1, const double * pMat2, const double dDiffMean, const int nTail, double * pStat = NULL, double * pDF = NULL, double * pProb = NULL )
 Parameters
    nRows[Input]minmum row number of input matrixsnCols[Input]minmum column number of input matrixspMat1[Input]pointer to input matrix for sample onepMat2[Input]pointer to input matrix for sample twodDiffMean[Input]Hypothetical difference between the means of the two samplesnTail[Input]Specify the alternative hypothesis of the t-test.allowed values: 0:Mean1 - Mean2 <> 0, 1:Mean1 - Mean2 > 0, 2:Mean1 - Mean2 < 0pStat[Output]The value of the t-test statistics, if not nullpDF[Output]The degrees of freedom of the t-test, if not nullpProb[Output]The associated p-value of the t-test, if not null ReturnReturn OE_NOERROR if succeed, otherwise, non-zero error code is returned ExamplesEX1 
void ocmath_row_ttest2_ex1()
{
    matrix mat1 = {{10,12,13,11},{13,10,11,12},{9,12,10,11}};
    matrix mat2 = {{13,10,11,12},{9,12,10,11}};
    int nRows = min(mat1.GetNumRows(), mat2.GetNumRows());
    int nCols = min(mat1.GetNumCols(), mat2.GetNumCols());
    mat1.SetSize(nRows, nCols, true);
    mat2.SetSize(nRows, nCols, true);
    
    vector stat, df, prob;
    stat.SetSize(nRows);
    df.SetSize(nRows);
    prob.SetSize(nRows);
    double difmean = 0.5, tail = TAILED_TEST_TWO;
    
    int nRet = ocmath_row_ttest2(nRows, nCols, mat1, mat2, difmean, tail, stat, df, prob);
    out_int("nRet=", nRet); //nRet = 0;
    
    //print out stat
    int ii;
    printf("stat = {");
    for(ii=0; ii<stat.GetSize(); ii++)
    {
        printf("%f\t", stat[ii]);
    }
    printf("}\n");    
    
    //print out df
    printf("df = {");
    for(ii=0; ii<df.GetSize(); ii++)
    {
        printf("%f\t", df[ii]);
    }
    printf("}\n");    
    //print out prob
    printf("prob = {");
    for(ii=0; ii<prob.GetSize(); ii++)
    {
        printf("%f\t", prob[ii]);
    }
    printf("}\n");    
}
RemarkSee Alsoheader to Includedorigin.h Reference |