如何使用numpy/scipy执行两样本单尾t检验 [英] How to perform two-sample one-tailed t-test with numpy/scipy

查看:139
本文介绍了如何使用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检验.我找到的有关该主题的最接近信息是

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?

推荐答案

从您的邮件列表链接:

因为单侧测试可以从双侧退出 测试. (对于对称分布,单侧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 < alpha and t > 0时大于检验和p/2 < alpha and 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检验的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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