Reputation: 501
Scipy(Python):
from scipy import stats
a=[3,4,5,8,9,1,2,4,5,3,8]
b=[6,19,3,2,14,4,5,17,1,2,4]
stats.ttest_ind(a,b, equal_var=True)
Ttest_indResult(statistic=-1.0810463365416798, pvalue=0.29254014390233507)
The result of Scipy is 0.292540
, Excel is 0.293487
. What the correct grammar to make the result of Scipy like the TTEST(a, b, 2, 1)
?
Upvotes: 1
Views: 799
Reputation:
There is a difference between paired and unpaired two-sample t-tests: see Wikipedia. The last parameter of Excel's TTEST
chooses between them:
=TTEST(A1:K1,A2:K2,2,1) # paired, returns 0.293487072
=TTEST(A1:K1,A2:K2,2,2) # unpaired, returns 0.292540144
In SciPy, these are done by
With your a, b
stats.ttest_rel(a, b) # pvalue=0.2934870715776284
stats.ttest_ind(a, b, equal_var=True) # pvalue=0.29254014390233507
Upvotes: 3