All problems
Normal CDF via erf
Problem
Normal cumulative distribution function evaluated at x using the error function.
F(x) = 0.5 * (1 + erf((x - mu) / (sigma * sqrt(2)))). Return 0.0 when sigma <= 0.
Hint
Standardize x into a z-score first.
Test cases
case 1
in: [0,0,1]
expected: 0.5
case 2
in: [1,0,1]
expected: 0.8413447460685429
case 3
in: [1.96,0,1]
expected: 0.9750021048517796
case 4
in: [0,0,-1]
expected: 0
Starter codePython
import math
def normal_cdf_erf(x, mu, sigma):
# Your code here
pass4 test cases · run your code against them in the editor