简体   繁体   中英

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM