[英]Calculating p-value with Python. One-tailed or two-tailed?
I'm using this function to calculate the p-value of an experiment I'm running.我正在使用这个 function 来计算我正在运行的实验的 p 值。 I'm not sure if it's one-tailed or two-tailed.
不知道是单尾还是双尾。 How can I infer this from the code?
我如何从代码中推断出这一点? Thanks
谢谢
from scipy import stats
def get_pvalue(con_conv, test_conv, con_size, test_size):
lift = - abs(test_conv - con_conv)
scale_one = con_conv * (1 - con_conv) * (1 / con_size)
scale_two = test_conv * (1 - test_conv) * (1 / test_size)
scale_val = (scale_one + scale_two)**0.5
p_value = 2 * stats.norm.cdf(lift, loc = 0, scale = scale_val )
return p_value
Two-tailed.二尾。 This can be inferred because the difference uses an absolute value, and the
p_value
multiplies the (one-sided) tail of the normal CDF by 2.这是可以推断的,因为差异使用了绝对值,并且
p_value
将正常 CDF 的(单边)尾部乘以 2。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.