ocmath_two_sample_t_test_pair

 

Description

Function to perform a Pair Two Sample t-Test for equal variance, assuming equal variance

Syntax

int ocmath_two_sample_t_test_pair( const double * pData1, UINT nSize1, const double * pData2, UINT nSize2, const HypotTestOptions * opt, tTestMean2SampleResults * res )

Parameters

pData1
[Input] pointers to 1st data points for Two Sample t-Test
nSize1
[Input] number of data points in pData1
pData2
[Input] pointers to 2nd data points for Two Sample t-Test
nSize2
[Input] number of data points in pData2
opt
[Input] structure containing t-Test options
res
[Output] structure containing t-Test Results

Return

Returns STATS_NO_ERROR on successful exit or a non-zero STATS error code on failure

Examples

EX1

bool two_sample_t_test_pair_ex1()
{
   int nRet;    
   bool bRet;
   //Notice: Size of vData1 and vData2 must be the same 
   vector vData1 = { 1.7, 2.1, 3.9, 7.2, 8.6, 8.5, 7.3, 5.1, 2.8, 1.8, 1.7 };
   vector vData2 = { 3.2, 3.9, 4.9, 5.3, 5.5, 6.2, 6.5, 6.9, 7.5, 8.3, 9.4 };     
   int nSize1 = vData1.GetSize();
   int nSize2 = vData2.GetSize();
   HypotTestOptions opt;                //Type defines in stats_types.h
   opt.HypotValue = 0;
   opt.TailType = TAILED_TEST_TWO;
   tTestMean2SampleResults res;        //Type defines in stats_types.h
   nRet = ocmath_two_sample_t_test_pair(vData1, nSize1, vData2, nSize2, &opt, &res);
   if ( STATS_NO_ERROR == nRet)    //Run successfully
   {
           printf("NUM1 = %d\nMean1 = %f\nSD1 = %f\nSEM1 = %f\n",res.N1, res.Mean1, res.SD1, res.SEM1);
           printf("NUM2 = %d\nMean2 = %f\nSD2 = %f\nSEM2 = %f\n",res.N2, res.Mean2, res.SD2, res.SEM2);
           printf("Mean difference = %f\nSEM difference = %d",res.DiffMean, res.DiffSEM);
           printf("DF = %d\nt statistic = %d\nprob = %f\n",res.DOF, res.tValue, res.Prob);
        ASSERT(0 == 11 - res.N1);
        ASSERT(is_equal(round(res.Mean1,4),round(4.60909,4)));
        ASSERT(is_equal(round(res.SD1,4),round(2.83106,4)));
        ASSERT(0 == 11 - res.N2);
        ASSERT(is_equal(round(res.Mean2,4),round(6.14545,4)));
        ASSERT(is_equal(round(res.SEM1,4),round(0.8536,4)));
        ASSERT(is_equal(round(res.SD2,4),round(1.84844,4)));
        ASSERT(is_equal(round(res.SEM2,4),round(0.55733,4)));
        ASSERT(is_equal(round(res.DiffMean,4),round(-1.53636,4)));
        ASSERT(is_equal(round(res.DiffSEM,4),round(0.29627,4)));
        ASSERT(0 == 10 - res.DOF);
        ASSERT(is_equal(round(res.tValue,4),round(-1.43241,4)));
        ASSERT(is_equal(round(res.Prob,4),round(0.18254,4)));
        bRet=TRUE;
   }
   else // Run unsuccessfully
   {
        ASSERT(0);
        bRet=FALSE;
   }
   
   return bRet;
}

Remark

See Also

header to Include

origin.h

Reference