| 28 | namespace stats { |
| 29 | |
| 30 | inline double dweibull_1(double x, double shape /*, double scale [=1.0] */ , int give_log){ |
| 31 | double tmp1, tmp2; |
| 32 | #ifdef IEEE_754 |
| 33 | if (ISNAN(x) || ISNAN(shape)) |
| 34 | return x + shape + 1.0; |
| 35 | #endif |
| 36 | if (shape <= 0) return R_NaN; |
| 37 | |
| 38 | if (x < 0) return R_D__0; |
| 39 | if (!R_FINITE(x)) return R_D__0; |
| 40 | /* need to handle x == 0 separately */ |
| 41 | if (x == 0 && shape < 1) return ML_POSINF; |
| 42 | tmp1 = ::pow(x, shape - 1); |
| 43 | tmp2 = tmp1 * x; |
| 44 | /* These are incorrect if tmp1 == 0 */ |
| 45 | return give_log ? |
| 46 | -tmp2 + ::log(shape * tmp1) : |
| 47 | shape * tmp1 * ::exp(-tmp2); |
| 48 | } |
| 49 | inline double pweibull_1(double x, double shape /*, double scale [=1.0] */, int lower_tail, int log_p) { |
| 50 | #ifdef IEEE_754 |
| 51 | if (ISNAN(x) || ISNAN(shape)) |