runif with .Machine$double.xmax as boundaries runif with .Machine$double.xmax as boundaries r r

runif with .Machine$double.xmax as boundaries


As hinted by mt1022 the reason is in runif C source:

double runif(double a, double b){    if (!R_FINITE(a) || !R_FINITE(b) || b < a)  ML_ERR_return_NAN;    if (a == b)    return a;    else {    double u;    /* This is true of all builtin generators, but protect against       user-supplied ones */    do {u = unif_rand();} while (u <= 0 || u >= 1);    return a + (b - a) * u;    }}

In the return argument you can see the formula a + (b - a) * u which transoform uniformly [0, 1] generated random value in the user supplied interval [a, b]. In your case it will be -M + (M + M) * u. So M + M in case it 1.79E308 + 1.79E308 generates Inf. I.e. finite + Inf * finite = Inf:

M + (M - m) * runif(1, 0, 1)# Inf