Day 4: Normal Distribution #1

  • + 0 comments

    erf and erfc, which are +- antiderivatives of the gaussian (with a specific choice of +c) is in the python math library. So, you can easily write the CDF of normal dist using either erf or erfc.

    import math
    
    mu = 30
    sig = 4
    def cdf(x):
        return math.erfc((mu-x)/(sig*math.sqrt(2)))/2
    print(cdf(40))
    print(1 - cdf(21))
    print(cdf(35)-cdf(30))