I would either ignore the possibility or raise an error. Returning NaN
isn't a very communicative way of saying "your RNG is buggy".
On 23 Sep 2013 19:07, "Jeremy T. Hetzel" <notifications@github.com> wrote:

> In numpy/random/mtrand/distributions.c:
>
> > +            (alpha + 1)*(c - b)*m*n + 2*(d - c)*m))) -
> > +            (((-2)*b*m*n*(1 - alpha))/(2*(c - b)) +
> > +            2*m*n*(((2*c - b)*(alpha - 1))/(2*(c - b)) + 1))/
> > +            (2*alpha*(b - a)*n + (alpha + 1)*(c - b)*m*n + 2*(d-c)*m))*
> > +            2*(c - b)*(2*alpha*(b-a)*n + (alpha + 1)*(c-b)*m*n + 2*(d - c)*m))/
> > +            (2*2*m*n*(1 - alpha));
> > +    }
> > +    else if ((pi1 < U) && (U <= (1 - pi3)) && (alpha == 1)) {
> > +        return b + (((U - pi1) / (pi2)) * (c - b));
> > +    }
> > +    else if (((1 - pi3) < U) && (U <= 1)) {
> > +        return d-pow((((1 - U)*(2*alpha*(b - a)*n + (alpha + 1)*(c - b)*m*n +
> > +            2*(d - c)*m))/(2*(d - c)*m)),(1/n))*(d - c);
> > +    }
> > +    else {
> > +        return NAN;
>
> I usually return NAN if the uniform random variate U is outside of [0, 1]
> and thus does not meet any of the conditions above. However,
> rk_double(state) should always return a value within [0, 1], and I don't
> see any of the other distributions in distributions.c returning NAN.
> Should this final else { return NAN;} condition be removed for
> consistency with the other distributions?
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/numpy/numpy/pull/3770/files#r6522263>
> .
>