All problems
Power of a One-Sided z-Test
Problem
Return the power 1 - Phi(z_alpha - delta*sqrt(n)/sigma) for a one-sided z-test with effect size delta, using the normal CDF. Return 0.0 when n <= 0 or sigma <= 0, and clamp the result to [0, 1].
Hint
The term delta*sqrt(n)/sigma is the noncentrality shift.
Test cases
case 1
in: [0.5,25,1,1.645]
expected: 0.8037244261254556
case 2
in: [0,100,2,1.96]
expected: 0.024997895148220428
case 3
in: [1,16,2,1.645]
expected: 0.6387052043836872
case 4
in: [2,9,1,1.28]
expected: 0.9999988207767835
case 5
in: [0.1,4,1,1]
expected: 0.21185539858339664
Starter codePython
import math
def power_one_sided_z(delta, n, sigma, z_alpha):
# Your code here
pass5 test cases · run your code against them in the editor