2.1.24.6.6 ocmath_row_ttest2


Description

Function 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 matrixs
nCols
[Input]minmum column number of input matrixs
pMat1
[Input]pointer to input matrix for sample one
pMat2
[Input]pointer to input matrix for sample two
dDiffMean
[Input]Hypothetical difference between the means of the two samples
nTail
[Input]Specify the alternative hypothesis of the t-test.
allowed values: 0:Mean1 - Mean2 <> 0, 1:Mean1 - Mean2 > 0, 2:Mean1 - Mean2 < 0
pStat
[Output]The value of the t-test statistics, if not null
pDF
[Output]The degrees of freedom of the t-test, if not null
pProb
[Output]The associated p-value of the t-test, if not null

Return

Return OE_NOERROR if succeed, otherwise, non-zero error code is returned

Examples

EX1

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");    
}

Remark

See Also

Header to Included

origin.h

Reference