All problems
One-Proportion z-Statistic
Problem
Return the one-proportion z-statistic (p_hat - p0) / sqrt(p0*(1-p0)/n), where p_hat = successes/n. Return 0.0 when n <= 0 or p0 is not strictly between 0 and 1.
Hint
The standard error uses the hypothesized proportion p0, not p_hat.
Test cases
case 1
in: [45,100,0.5]
expected: -0.9999999999999998
case 2
in: [60,100,0.5]
expected: 1.9999999999999996
case 3
in: [10,50,0.2]
expected: 0
case 4
in: [0,0,0.5]
expected: 0
case 5
in: [5,10,0.9]
expected: -4.216370213557839
Starter codePython
def one_proportion_z(successes, n, p0):
# Your code here
pass5 test cases · run your code against them in the editor