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
评论列表
文章目录