Welch's t-test: Difference between revisions
Content added Content deleted
m (contradiction with the following sentence (it's a translation of a specific R command)) |
m (→{{header|C}}: removed redundant variable 'x', should save RAM and make easier to read) |
||
Line 130: | Line 130: | ||
); |
); |
||
// printf("Welch = %lf DOF = %lf\n", WELCH_T_STATISTIC, DEGREES_OF_FREEDOM); |
// printf("Welch = %lf DOF = %lf\n", WELCH_T_STATISTIC, DEGREES_OF_FREEDOM); |
||
const double a = DEGREES_OF_FREEDOM/2; |
|||
double value = DEGREES_OF_FREEDOM/(WELCH_T_STATISTIC*WELCH_T_STATISTIC+DEGREES_OF_FREEDOM); |
|||
if ((isinf( |
if ((isinf(value) != 0) || (isnan(value) != 0)) { |
||
return 1.0; |
return 1.0; |
||
} |
} |
||
if ((isinf( |
if ((isinf(value) != 0) || (isnan(value) != 0)) { |
||
return 1.0; |
return 1.0; |
||
} |
} |
||
/* Purpose: |
|||
BETAIN computes the incomplete Beta function ratio. |
BETAIN computes the incomplete Beta function ratio. |
||
Line 192: | Line 193: | ||
double temp; |
double temp; |
||
double term; |
double term; |
||
double value; |
|||
double xx; |
double xx; |
||
value = x; |
|||
// ifault = 0; |
// ifault = 0; |
||
//Check the input arguments. |
//Check the input arguments. |
||
Line 202: | Line 201: | ||
// return value; |
// return value; |
||
} |
} |
||
if ( |
if ( value < 0.0 || 1.0 < value ) |
||
{ |
{ |
||
// *ifault = 2; |
// *ifault = 2; |
||
Line 210: | Line 209: | ||
Special cases. |
Special cases. |
||
*/ |
*/ |
||
if ( |
if ( value == 0.0 || value == 1.0 ) { |
||
return value; |
return value; |
||
} |
} |
||
psq = a + 0.5; |
psq = a + 0.5; |
||
cx = 1.0 - |
cx = 1.0 - value; |
||
if ( a < psq * |
if ( a < psq * value ) |
||
{ |
{ |
||
xx = cx; |
xx = cx; |
||
cx = |
cx = value; |
||
pp = 0.5; |
pp = 0.5; |
||
qq = a; |
qq = a; |
||
Line 226: | Line 225: | ||
else |
else |
||
{ |
{ |
||
xx = |
xx = value; |
||
pp = a; |
pp = a; |
||
qq = 0.5; |
qq = 0.5; |
||
Line 281: | Line 280: | ||
} |
} |
||
} |
} |
||
return value; |
return value; |
||
} |
} |