How to perform two-sample one-tailed t-test with numpy/scipy(如何使用 numpy/scipy 执行两样本单尾 t 检验)
问题描述
在R
中,可以简单地使用
> A = c(0.19826790, 1.36836629, 1.37950911, 1.46951540, 1.48197798, 0.07532846)
> B = c(0.6383447, 0.5271385, 1.7721380, 1.7817880)
> t.test(A, B, alternative="greater")
Welch Two Sample t-test
data: A and B
t = -0.4189, df = 6.409, p-value = 0.6555
alternative hypothesis: true difference in means is greater than 0
95 percent confidence interval:
-1.029916 Inf
sample estimates:
mean of x mean of y
0.9954942 1.1798523
在 Python 世界中,scipy
提供了类似的功能 ttest_ind,但它只能做双尾 t 检验.我发现的关于该主题的最近信息是 this 链接,但它似乎是对 scipy
中实现单尾与双尾策略的讨论.
In Python world, scipy
provides similar function ttest_ind, but which can only do two-tailed t-tests. Closest information on the topic I found is this link, but it seems to be rather a discussion of the policy of implementing one-tailed vs two-tailed in scipy
.
因此,我的问题是,有没有人知道有关如何使用 numpy/scipy
执行单尾版本测试的任何示例或说明?
Therefore, my question is that does anyone know any examples or instructions on how to perform one-tailed version of the test using numpy/scipy
?
推荐答案
来自您的邮件列表链接:
From your mailing list link:
因为单面测试可以从双面退出测试.(对于对称分布,一侧 p 值仅为一半两侧 pvalue)
because the one-sided tests can be backed out from the two-sided tests. (With symmetric distributions one-sided p-value is just half of the two-sided pvalue)
接着说 scipy 总是给出带符号的测试统计量.这意味着给定来自双尾检验的 p 和 t 值,当 p/2 <;α 和 t >0
,当 p/2 <α 和 t <0
.
It goes on to say that scipy always gives the test statistic as signed. This means that given p and t values from a two-tailed test, you would reject the null hypothesis of a greater-than test when p/2 < alpha and t > 0
, and of a less-than test when p/2 < alpha and t < 0
.
这篇关于如何使用 numpy/scipy 执行两样本单尾 t 检验的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 numpy/scipy 执行两样本单尾 t 检验


基础教程推荐
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- 筛选NumPy数组 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01