| 76 | } |
| 77 | |
| 78 | inline double pnorm_0(double x /*, double mu [=0.] , double sigma [=1.]*/ , int lower_tail, int log_p) { |
| 79 | double p, cp; |
| 80 | |
| 81 | /* Note: The structure of these checks has been carefully thought through. |
| 82 | * For example, if x == mu and sigma == 0, we get the correct answer 1. |
| 83 | */ |
| 84 | #ifdef IEEE_754 |
| 85 | if (ISNAN(x)) |
| 86 | return x + 1.0; |
| 87 | #endif |
| 88 | p = x; |
| 89 | if (!R_FINITE(p)) |
| 90 | return (x < 0.0) ? R_DT_0 : R_DT_1; |
| 91 | x = p; |
| 92 | |
| 93 | ::Rf_pnorm_both(x, &p, &cp, (lower_tail ? 0 : 1), log_p); |
| 94 | |
| 95 | return(lower_tail ? p : cp); |
| 96 | } |
| 97 | |
| 98 | inline double qnorm_1(double p, double mu /*, double sigma [=1.] */, |
| 99 | int lower_tail, int log_p){ |