statistics.py 文件源码

python
阅读 40 收藏 0 点赞 0 评论 0

项目:expan 作者: zalando 项目源码 文件源码
def _get_power(mean1, std1, n1, mean2, std2, n2, z_1_minus_alpha):
    """
    Compute statistical power.
    This is a helper function for compute_statistical_power(x, y, alpha=0.05)
    Args:
        mean1 (float): mean value of the treatment distribution
        std1 (float): standard deviation of the treatment distribution
        n1 (integer): number of samples of the treatment distribution
        mean2 (float): mean value of the control distribution
        std2 (float): standard deviation of the control distribution
        n2 (integer): number of samples of the control distribution
        z_1_minus_alpha (float): critical value for significance level alpha. That is, z-value for 1-alpha.

    Returns:
        float: statistical power --- that is, the probability of a test to detect an effect,
            if the effect actually exists.
    """
    effect_size = mean1 - mean2
    std = pooled_std(std1, n1, std2, n2)
    tmp = (n1 * n2 * effect_size**2) / ((n1 + n2) * std**2)
    z_beta = z_1_minus_alpha - np.sqrt(tmp)
    beta = stats.norm.cdf(z_beta)
    power = 1 - beta

    return power
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号