All problems
Two-Proportion Z-Score
Problem
Compute the pooled two-proportion z-score: (p_a - p_b) / sqrt(p_pool * (1 - p_pool) * (1/n_a + 1/n_b)), where p_pool = (success_a + success_b) / (n_a + n_b).
Return 0.0 when a sample size is 0 or the standard error is 0.
Hint
The pooled proportion combines both groups under the null hypothesis of equal rates.
Test cases
case 1
in: [60,1000,50,1000]
expected: 0.980816477227499
case 2
in: [100,500,80,500]
expected: 1.6462159944159829
case 3
in: [50,100,50,100]
expected: 0
case 4
in: [0,100,0,100]
expected: 0
Starter codePython
import math
def two_proportion_z(success_a, n_a, success_b, n_b):
# Your code here
pass4 test cases · run your code against them in the editor