24#ifndef Rcpp__stats__weibull_h
25#define Rcpp__stats__weibull_h
33 if (ISNAN(x) || ISNAN(shape))
34 return x + shape + 1.0;
36 if (shape <= 0)
return R_NaN;
39 if (!R_FINITE(x))
return R_D__0;
41 if (x == 0 && shape < 1)
return ML_POSINF;
42 tmp1 =
::pow(x, shape - 1);
46 -tmp2 + ::log(shape * tmp1) :
47 shape * tmp1 * ::exp(-tmp2);
49inline double pweibull_1(
double x,
double shape ,
int lower_tail,
int log_p) {
51 if (ISNAN(x) || ISNAN(shape))
52 return x + shape + 1.0;
54 if (shape <= 0)
return R_NaN;
58 x = -
::pow(x , shape);
62 ? (x > -M_LN2 ? ::log(-::expm1(x)) : ::log1p(-::exp(x)))
67inline double qweibull_1(
double p,
double shape ,
int lower_tail,
int log_p){
69 if (ISNAN(p) || ISNAN(shape))
70 return p + shape + 1.0;
72 if (shape <= 0)
return R_NaN;
83RCPP_DPQ_2(weibull,::Rf_dweibull,::Rf_pweibull,::Rf_qweibull)
#define RCPP_DPQ_2(__NAME__, __D__, __P__, __Q__)
#define RCPP_DPQ_1(__NAME__, __D__, __P__, __Q__)
double dweibull_1(double x, double shape, int give_log)
double pweibull_1(double x, double shape, int lower_tail, int log_p)
double qweibull_1(double p, double shape, int lower_tail, int log_p)
sugar::Pow< RTYPE, NA, T, EXPONENT_TYPE > pow(const VectorBase< RTYPE, NA, T > &t, EXPONENT_TYPE exponent)
#define R_Q_P01_boundaries(p, _LEFT_, _RIGHT_)