All problems
Statistical Power
Problem
Compute the power of a one-sided z-test: 1 - Phi(z_alpha - delta * sqrt(n) / sigma), where Phi is the standard normal CDF.
Return 0.0 when n <= 0 or sigma <= 0.
Hint
Power is the probability of rejecting the null when the true effect is delta.
Test cases
case 1
in: [100,0.2,1,1.645]
expected: 0.6387052043836872
case 2
in: [400,0.1,1,1.96]
expected: 0.5159534368528308
case 3
in: [50,0.5,2,1.28]
expected: 0.6871425391678323
case 4
in: [0,0.2,1,1.645]
expected: 0
Starter codePython
import math
def statistical_power(n, delta, sigma, z_alpha):
# Your code here
pass4 test cases · run your code against them in the editor