Using Φ via math.erf, compute the one-sided and two-sided p-values for z = −1.90, then the two-sided p-value for z = 2.31, printed to four decimals.
Using Φ via math.erf, compute the one-sided and two-sided p-values for z = −1.90, then the two-sided p-value for z = 2.31, printed to four decimals.
Answer
import math def phi(z): return 0.5 * (1 + math.erf(z / math.sqrt(2))) z = -1.90 one = phi(-abs(z)) print(f"p one-sided={one:.4f} p two-sided={2 * one:.4f}") z2 = 2.31 print(f"z={z2} p two-sided={2 * phi(-abs(z2)):.4f}")
IS1 §9.4 (rare-events framing), CC BY 4.0; BCc ch 5 ("the smallest α that rejects"; software prints two-sided); H-W9 — shape only; original dataset