def t_two_sample(a, b, tails='two-sided', exp_diff=0):
 if ((len(a) == 1) or (len(b) == 1)):
  if (len(a) <= len(b)):
   (t, p) = t_one_observation(a, b, tails, exp_diff)
  else:
   (t, p) = t_one_observation(b, a, tails, exp_diff)
  return (t, p)
 (t, _) = ttest_ind((asarray(a) - exp_diff), asarray(b), axis=0, equal_var=True)
 if (isnan(t) or isinf(t)):
  return (nan, nan)
 p = tprob(t, ((len(a) + len(b)) - 2.0), tails)
 return (float(t), p)

def t_two_sample ( a , b , tails = 'two-sided' , exp_diff = 0 ) : if ( ( len ( a ) == 1 ) or ( len ( b ) == 1 ) ) : if ( len ( a ) <= len ( b ) ) : ( t , p ) = t_one_observation ( a , b , tails , exp_diff ) else : ( t , p ) = t_one_observation ( b , a , tails , exp_diff ) return ( t , p ) ( t , _ ) = ttest_ind ( ( asarray ( a ) - exp_diff ) , asarray ( b ) , axis = 0 , equal_var = True ) if ( isnan ( t ) or isinf ( t ) ) : return ( nan , nan ) p = tprob ( t , ( ( len ( a ) + len ( b ) ) - 2.0 ) , tails ) return ( float ( t ) , p )
scipy t_two_sample .