Пример #1
0
double qztbinom(double x, double size, double prob, int lower_tail, int log_p)
{
#ifdef IEEE_754
    if (ISNAN(x) || ISNAN(size) || ISNAN(prob))
	return x + size + prob;
#endif
    if (prob < 0 || prob > 1 || size < 1) return R_NaN;

    /* limiting cases as size -> 1 or prob -> 0 are point mass at one */
    if (size == 1 || prob == 0)
    {
	/* simplified ACT_Q_P01_boundaries macro */
	if (log_p)
	{
	    if (x > 0)
		return R_NaN;
	    return 1.0;
	}
	else /* !log_p */
	{
	    if (x < 0 || x > 1)
		return R_NaN;
	    return 1.0;
	}
    }

    ACT_Q_P01_boundaries(x, 1, size);
    x = ACT_DT_qIv(x);

    double p0 = dbinom_raw(0, size, prob, 1 - prob, /*give_log*/0);

    return qbinom(p0 + (1 - p0) * x, size, prob, /*l._t.*/1, /*log_p*/0);
}
Пример #2
0
double qztgeom(double x, double prob, int lower_tail, int log_p)
{
#ifdef IEEE_754
    if (ISNAN(x) || ISNAN(prob))
	return x + prob;
#endif
    if (prob <= 0 || prob > 1) return R_NaN;

    /* limiting case as prob approaches one is point mass at one */
    if (prob == 1)
    {
	/* simplified ACT_Q_P01_boundaries macro */
	if (log_p)
	{
	    if (x > 0)
		return R_NaN;
	    return 1.0;
	}
	else /* !log_p */
	{
	    if (x < 0 || x > 1)
		return R_NaN;
	    return 1.0;
	}
    }

    ACT_Q_P01_boundaries(x, 1, R_PosInf);
    x = ACT_DT_qIv(x);

    return 1 + qgeom(x, prob, /*l._t.*/1, /*log_p*/0);
}
Пример #3
0
double qinvexp(double p, double scale, int lower_tail, int log_p)
{
    if (!R_FINITE(scale) || scale <= 0.0)
        return R_NaN;

    ACT_Q_P01_boundaries(p, 0, R_PosInf);
    p = ACT_D_qIv(p);

    return -scale / log(ACT_D_Lval(p));
}
Пример #4
0
double qinvpareto(double p, double shape, double scale, int lower_tail,
                  int log_p)
{
    if (!R_FINITE(shape) ||
        !R_FINITE(scale) ||
        shape <= 0.0 ||
        scale <= 0.0)
        return R_NaN;;

    ACT_Q_P01_boundaries(p, 0, R_PosInf);
    p = ACT_D_qIv(p);

    return scale / (R_pow(ACT_D_Lval(p), -1.0 / shape) - 1.0);
}
Пример #5
0
double qinvexp(double p, double scale, int lower_tail, int log_p)
{
#ifdef IEEE_754
    if (ISNAN(p) || ISNAN(scale))
	return p + scale;
#endif
    if (!R_FINITE(scale) || scale <= 0.0)
        return R_NaN;

    ACT_Q_P01_boundaries(p, 0, R_PosInf);
    p = ACT_D_qIv(p);

    return -scale / log(ACT_D_Lval(p));
}
Пример #6
0
double qpareto1(double p, double shape, double min, int lower_tail, int log_p)
{
#ifdef IEEE_754
    if (ISNAN(p) || ISNAN(shape) || ISNAN(min))
	return p + shape + min;
#endif
    if (!R_FINITE(shape) ||
        !R_FINITE(min)   ||
        shape <= 0.0 ||
        min <= 0.0)
        return R_NaN;

    ACT_Q_P01_boundaries(p, min, R_PosInf);
    p = ACT_D_qIv(p);

    return min / R_pow(ACT_D_Cval(p), 1.0 / shape);
}
Пример #7
0
double qinvparalogis(double p, double shape, double scale, int lower_tail,
                     int log_p)
{
    double tmp;

    if (!R_FINITE(shape) ||
        !R_FINITE(scale) ||
        shape <= 0.0 ||
        scale <= 0.0)
        return R_NaN;;

    ACT_Q_P01_boundaries(p, 0, R_PosInf);
    p = ACT_D_qIv(p);

    tmp = -1.0 / shape;

    return scale * R_pow(R_pow(ACT_D_Lval(p), tmp) - 1.0, tmp);
}