This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
functions { | |
real binormal_cdf(real z1, real z2, real rho) { | |
if (z1 != 0 || z2 != 0) { | |
real denom = fabs(rho) < 1.0 ? sqrt((1 + rho) * (1 - rho)) : not_a_number(); | |
real a1 = (z2 / z1 - rho) / denom; | |
real a2 = (z1 / z2 - rho) / denom; | |
real product = z1 * z2; | |
real delta = product < 0 || (product == 0 && (z1 + z2) < 0); | |
return 0.5 * (Phi(z1) + Phi(z2) - delta) - owens_t(z1, a1) - owens_t(z2, a2); | |
} |