gpt4 book ai didi

python - 为什么 Scipy 中的 ttest_ind 与 Excel TTest 略有不同?

转载 作者:行者123 更新时间:2023-12-01 09:13:00 28 4
gpt4 key购买 nike

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)

Excel: enter image description here

Scipy的结果是0.292540,Excel的结果是0.293487。使 Scipy 的结果类似于 TTEST(a, b, 2, 1) 的正确语法是什么?

最佳答案

配对未配对双样本 t 检验之间存在差异:请参阅 Wikipedia 。 Excel 的 TTEST 的最后一个参数在它们之间进行选择:

=TTEST(A1:K1,A2:K2,2,1)   # paired, returns   0.293487072
=TTEST(A1:K1,A2:K2,2,2) # unpaired, returns 0.292540144

在 SciPy 中,这些是由

完成的
  • ttest_rel (配对;“rel”代表相关)
  • ttest_ind (未配对,“ind”代表独立)

用你的a,b

stats.ttest_rel(a, b)                   # pvalue=0.2934870715776284
stats.ttest_ind(a, b, equal_var=True) # pvalue=0.29254014390233507

关于python - 为什么 Scipy 中的 ttest_ind 与 Excel TTest 略有不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51494185/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com