All problems
p-Value from z (One-Sided)
Problem
Return the one-sided upper-tail p-value 1 - Phi(z) = 0.5*(1 - erf(z/sqrt(2))) for a standard normal test statistic. Large positive z gives a small p-value.
Hint
Use math.erf for the normal CDF.
Test cases
case 1
in: [0]
expected: 0.5
case 2
in: [1.96]
expected: 0.024997895148220428
case 3
in: [-1.645]
expected: 0.9500150944608786
case 4
in: [2.326]
expected: 0.010009275340867707
case 5
in: [3]
expected: 0.0013498980316301035
Starter codePython
import math
def p_value_z_one_sided(z):
# Your code here
pass5 test cases · run your code against them in the editor