| 28 | namespace stats { |
| 29 | |
| 30 | inline double dlnorm_0(double x, int log_p){ |
| 31 | double y; |
| 32 | |
| 33 | #ifdef IEEE_754 |
| 34 | if (ISNAN(x)) |
| 35 | return x + 1.0; |
| 36 | #endif |
| 37 | |
| 38 | if (x <= 0) return R_D__0; |
| 39 | |
| 40 | y = ::log(x); |
| 41 | return (log_p ? |
| 42 | -(M_LN_SQRT_2PI + 0.5 * y * y + ::log(x)) : |
| 43 | M_1_SQRT_2PI * ::exp(-0.5 * y * y) / x); |
| 44 | /* M_1_SQRT_2PI = 1 / sqrt(2 * pi) */ |
| 45 | } |
| 46 | |
| 47 | inline double dlnorm_1(double x, double meanlog, int log_p){ |
| 48 | double y; |