Since rand() has been (at this point) agreed to return a value in [0,1) , there is the remote possibility of returning true when sampling a Bernoulli(0.0) distribution if we use <=. Changing this to < removes this possibility.
On the other side of [0,1) , Bernoulli(1.0) still always returns true as expected.
An argument against accepting this PR might be the change in probability of returning true on all intermediate values. As the sampling is not mathematically perfect but limited to computer representation, the current rand() might be closer to mathematical Bernoulli(p) with <=.
Since
rand()
has been (at this point) agreed to return a value in [0,1) , there is the remote possibility of returningtrue
when sampling aBernoulli(0.0)
distribution if we use<=
. Changing this to<
removes this possibility.On the other side of [0,1) ,
Bernoulli(1.0)
still always returnstrue
as expected.An argument against accepting this PR might be the change in probability of returning
true
on all intermediate values. As the sampling is not mathematically perfect but limited to computer representation, the currentrand()
might be closer to mathematical Bernoulli(p) with<=
.