来自 t 统计的 Python p 值

标签 python scipy statistics

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

例如

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

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

最佳答案

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

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 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17559897/

相关文章:

python - 使用 python-c-api 调用的 Cython 回调段错误

Python最大递归,关于sys.setrecursionlimit()的问题

python - 高效测地线最近邻

python - PyDSTool 无法识别 SciPy 版本

python - 带 fsolve 的方程系统

statistics - 词使用数据库?

matlab - MATLAB 中的 GMM 对于同一文件给出不同的结果

python - int() 与 .astype ('int' ) Python

python - 存储在矩阵中的图像的边缘检测

php - 重定向用户,然后使用 php 和 mysql 记录他的访问