subroutine ttest ( t, df, ans, kerr ) c*********************************************************************72 c cc ttest c implicit none real ans real d1 real d2 integer df real f1 real f2 integer i integer kerr integer n real t real t1 real t2 save d1 data d1 / 0.63661977236758134e+00 / c c 0.63661977236758134... = 2 / pi c kerr = 0 c c error return if df not positive. c if ( df .le. 0 ) then kerr = 1 ans = 0.0e+00 return end if c c begin computation of series. c t2 = t * t / float ( df ) t1 = sqrt ( t2 ) t2 = 1.0e+00 / ( 1.0e+00 + t2 ) if ( ( df / 2 ) * 2 .eq. df ) go to 5 c c df is an odd integer. c ans = 1.0e+00 - d1 * atan ( t1 ) if ( df .eq. 1 ) go to 4 d2 = d1 * t1 * t2 ans = ans - d2 if ( df .eq. 3 ) go to 4 f1 = 0.0e+00 2 n = ( df - 2 ) / 2 do i = 1, n f2 = 2.0e+00 * float ( i ) - f1 d2 = d2 * t2 * f2 / ( f2 + 1.0e+00 ) ans = ans - d2 end do c c common return after computation. c 4 continue if ( ans .lt. 0.0e+00 ) then ans = 0.0e+00 end if return c c df is an even integer. c 5 continue d2 = t1 * sqrt ( t2 ) ans = 1.0e+00 - d2 if ( df .eq. 2 ) go to 4 f1 = 1.0e+00 go to 2 end