##########################################################################1#2# Copyright (C) 2007 William Stein <[email protected]>3# 2007 Mike Hansen <[email protected]>4# 2008 Harald Schilly <[email protected]>5#6# Distributed under the terms of the GNU General Public License (GPL)7#8# http://www.gnu.org/licenses/9#10##########################################################################1112from sage.interfaces.r import R1314# my own copy of an R interface15myR = R()1617def ttest(x,y,conf_level = 0.95, **kw):18"""19T-Test using R2021Arguments:22x, y -- vectors of same length23conf_level -- confidence level of the interval, [0,1) in percent2425Result:26Tuple: (p-value, R return object)2728Example:29sage: a, b = ttest([1,2,3,4,5],[1,2,3,3.5,5.121]); a300.94102637202742731"""32if len(x) != len(y):33raise AttributeError, "vectors x and y must be of same length"3435test = myR.t_test(x,y,conf_level = conf_level, **kw)._sage_()36t = test.get('DATA').get('p_value')37return t, test383940