def _tconfint_generic(mean, std_mean, dof, alpha, alternative):
 if (alternative in ['two-sided', '2-sided', '2s']):
  tcrit = stats.t.ppf((1 - (alpha / 2.0)), dof)
  lower = (mean - (tcrit * std_mean))
  upper = (mean + (tcrit * std_mean))
 elif (alternative in ['larger', 'l']):
  tcrit = stats.t.ppf(alpha, dof)
  lower = (mean + (tcrit * std_mean))
  upper = np.inf
 elif (alternative in ['smaller', 's']):
  tcrit = stats.t.ppf((1 - alpha), dof)
  lower = (- np.inf)
  upper = (mean + (tcrit * std_mean))
 else:
  raise ValueError('invalid alternative')
 return (lower, upper)

def _tconfint_generic ( mean , std_mean , dof , alpha , alternative ) : if ( alternative in [ 'two-sided' , '2-sided' , '2s' ] ) : tcrit = stats . t . ppf ( ( 1 - ( alpha / 2.0 ) ) , dof ) lower = ( mean - ( tcrit * std_mean ) ) upper = ( mean + ( tcrit * std_mean ) ) elif ( alternative in [ 'larger' , 'l' ] ) : tcrit = stats . t . ppf ( alpha , dof ) lower = ( mean + ( tcrit * std_mean ) ) upper = np . inf elif ( alternative in [ 'smaller' , 's' ] ) : tcrit = stats . t . ppf ( ( 1 - alpha ) , dof ) lower = ( - np . inf ) upper = ( mean + ( tcrit * std_mean ) ) else : raise ValueError ( 'invalid alternative' ) return ( lower , upper )
generic t-confint to save typing .