All problems
Power from Effect Size
Problem
For a one-sided z-test, the power is Phi(delta * sqrt(n) - z_alpha) where delta is the standardized effect size. Use the normal CDF implementation Phi(x) = 0.5 (1 + erf(x / sqrt(2))).
Given delta, n, and the critical z_alpha, return [power, beta] where beta = 1 - power.
Hint
Shift the critical value by the noncentrality delta * sqrt(n).
Test cases
case 1
in: [0.5,25,1.645]
expected: [0.8037244261254556,0.19627557387454442]
case 2
in: [0.2,100,1.96]
expected: [0.5159534368528308,0.4840465631471692]
case 3
in: [0,30,1.645]
expected: [0.04998490553912138,0.9500150944608786]
Starter codePython
def power_from_effect_size(delta, n, z_alpha):
# Your code here
pass3 test cases · run your code against them in the editor