| 229 | |
| 230 | |
| 231 | double |
| 232 | CorrelatedStandardNormal::getCDF(double b1, double b2) |
| 233 | { |
| 234 | static NormalRV uRV(1, 0.0, 1.0); |
| 235 | double cdf = 0.0; |
| 236 | int popt = 0; |
| 237 | |
| 238 | // treat several special cases before attempting to integrate numerically |
| 239 | if ( 1.0 - rho <= DBL_EPSILON ) { |
| 240 | // rho = 1 |
| 241 | if (b1 >= b2 && b1 >= 0) |
| 242 | cdf = 2.0 - uRV.getCDFvalue(b1) - uRV.getCDFvalue(-b1) - uRV.getCDFvalue(-b2); |
| 243 | else if (b2 > b1 && b2 >= 0) |
| 244 | cdf = 2.0 - uRV.getCDFvalue(b2) - uRV.getCDFvalue(-b1) - uRV.getCDFvalue(-b2); |
| 245 | else if (-b1 >= -b2) |
| 246 | cdf = 1.0 - uRV.getCDFvalue(-b1); |
| 247 | else |
| 248 | cdf = 1.0 - uRV.getCDFvalue(-b2); |
| 249 | |
| 250 | } else if ( 1.0 + rho <= DBL_EPSILON ) { |
| 251 | // rho = -1 |
| 252 | if (b1 + b2 >= 0) |
| 253 | cdf = 1.0 - uRV.getCDFvalue(-b1) - uRV.getCDFvalue(-b2); |
| 254 | else |
| 255 | cdf = 0.0; |
| 256 | |
| 257 | } else { |
| 258 | // single integral form by Owen 1956 |
| 259 | //cdf = getCDFowen(b1,b2,popt); |
| 260 | |
| 261 | // single integral form by Sheppard 1900 |
| 262 | cdf = getCDFsheppard(b1,b2,popt); |
| 263 | |
| 264 | // adaptive quadrature from Quan |
| 265 | //cdf = getCDFadaptive(b1,b2,popt); |
| 266 | } |
| 267 | |
| 268 | if (cdf > 1) |
| 269 | cdf = 1.0; |
| 270 | if (cdf < 0) |
| 271 | cdf = 0.0; |
| 272 | |
| 273 | return cdf; |
| 274 | } |
| 275 | |
| 276 | |
| 277 | double |
no test coverage detected