来自 t 统计量的 Python p 值 [英] Python p-value from t-statistic

查看:43
本文介绍了来自 t 统计量的 Python p 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些 t 值和自由度,想从中找到 p 值(它是双尾的).在现实世界中,我会使用统计学教科书后面的 t 检验表;我如何在 Python 中执行等效操作?

I have some t-values and degrees of freedom and want to find the p-values from them (it's two-tailed). In the real world I would use a t-test table in the back of a Statistics textbook; how do I do the equivalent in Python?

例如

t-lookup(5, 7) = 0.00245 或类似的东西.

我知道在 SciPy 中如果我有数组我可以做 scipy.stats.ttest_ind,但我没有.我只有 t 统计量和自由度.

I know in SciPy if I had arrays I could do scipy.stats.ttest_ind, but I don't. I just have t-statistics and degrees of freedom.

推荐答案

来自http://docs.scipy.org/doc/scipy/reference/tutorial/stats.html

作为练习,我们也可以直接计算我们的 ttest 而不使用提供的函数,它应该给我们相同的答案,所以它确实:

As an exercise, we can calculate our ttest also directly without using the provided function, which should give us the same answer, and so it does:

tt = (sm-m)/np.sqrt(sv/float(n))  # t-statistic for mean
pval = stats.t.sf(np.abs(tt), n-1)*2  # two-sided pvalue = Prob(abs(t)>tt)
print 't-statistic = %6.3f pvalue = %6.4f' % (tt, pval)
t-statistic =  0.391 pvalue = 0.6955

这篇关于来自 t 统计量的 Python p 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆