def normal_lccdf(mu, sigma, x): z = (x - mu) / sigma return aet.switch( aet.gt(z, 1.0), aet.log(aet.erfcx(z / aet.sqrt(2.0)) / 2.0) - aet.sqr(z) / 2.0, aet.log1p(-aet.erfc(-z / aet.sqrt(2.0)) / 2.0), )
def normal_lcdf(mu, sigma, x): """Compute the log of the cumulative density function of the normal.""" z = (x - mu) / sigma return aet.switch( aet.lt(z, -1.0), aet.log(aet.erfcx(-z / aet.sqrt(2.0)) / 2.0) - aet.sqr(z) / 2.0, aet.log1p(-aet.erfc(z / aet.sqrt(2.0)) / 2.0), )
def invprobit(x): return 0.5 * erfc(-x / sqrt(2.0))