View | Details | Raw Unified | Return to bug 17155
Collapse All | Expand All

(-)src/nmath/rbeta.c (-7 / +12 lines)
Lines 34-48 Link Here
34
{
34
{
35
    if (aa < 0. || bb < 0.)
35
    if (aa < 0. || bb < 0.)
36
	ML_ERR_return_NAN;
36
	ML_ERR_return_NAN;
37
    if (!R_FINITE(aa) && !R_FINITE(bb)) // a = b = Inf : all mass at 1/2
37
    if (!R_FINITE(aa) || !R_FINITE(bb)){
38
	return 0.5;
38
        // a = b = Inf : all mass at 1/2
39
        if (aa == R_PosInf && bb == R_PosInf)
40
            return 0.5;
41
        if (aa == R_PosInf)
42
            return 1.0;
43
        if (bb == R_PosInf)
44
            return 0.0;
45
        // if neither a or b is infinite, a or b is NA
46
        return NA_REAL;
47
    }
48
    
39
    if (aa == 0. && bb == 0.) // point mass 1/2 at each of {0,1} :
49
    if (aa == 0. && bb == 0.) // point mass 1/2 at each of {0,1} :
40
	return (unif_rand() < 0.5) ? 0. : 1.;
50
	return (unif_rand() < 0.5) ? 0. : 1.;
41
    // now, at least one of a, b is finite and positive
42
    if (!R_FINITE(aa) || bb == 0.)
43
    	return 1.0;
44
    if (!R_FINITE(bb) || aa == 0.)
45
    	return 0.0;
46
51
47
    double a, b, alpha;
52
    double a, b, alpha;
48
    double r, s, t, u1, u2, v, w, y, z;
53
    double r, s, t, u1, u2, v, w, y, z;

Return to bug 17155