42 Float pbeta_raw(Float x, Float a, Float b,
int lower_tail,
int log_p)
45 if(a == 0 || b == 0 || !R_FINITE(a) || !R_FINITE(b)) {
48 return (log_p ? -M_LN2 : 0.5);
49 if (a == 0 || a/b == 0)
51 if (b == 0 || b/a == 0)
54 if (x < 0.5)
return R_DT_0;
else return R_DT_1;
58 Float x1 = 0.5 - x + 0.5, w, wc;
61 bratio(a, b, x, x1, &w, &wc, &ierr, log_p);
64 if(ierr && ierr != 11 && ierr != 14)
65 MATHLIB_WARNING4(_(
"pbeta_raw(%g, a=%g, b=%g, ..) -> bratio() gave error code %d"),
67 return lower_tail ? w : wc;
71 Float
pbeta(Float x, Float a, Float b,
int lower_tail,
int log_p)
74 if (ISNAN(x) || ISNAN(a) || ISNAN(b))
return x + a + b;
77 if (a < 0 || b < 0) ML_ERR_return_NAN;
85 return pbeta_raw(x, a, b, lower_tail, log_p);
Type pbeta(Type q, Type shape1, Type shape2)
Distribution function of the beta distribution (following R argument convention). ...