Closed jaltevogt closed 2 years ago
It is caused by underflow/overflow. Those p are too large (very close to 1). Although we can harden the code to throw exceptions in such case, it may not be very useful for random number generations.
A workaround is to use a large n (e.g. 10x) and then scale down the random number by dividing 10.
Thanks, scaling down works. I'm not familiar with the inner workings of the rng, but I just realized BinomialDistribution.rand() uses PoissonDistribution.tinyLambdaRand() as a workaround in case n*p < 1.E-6 . Should this workaroun be used in case p/n<1.E-6 or (1-p)/n < 1.E-6 .
I made some enhancement. It works fine with your examples. Please try master branch.
Thanks for the fix!
For carefully selected success rate p ~=0.999000999000999 the binomial distributions random number generator seems bugged. Maybe some numerical instabilities?
Code snippet:
results in:
Can you reproduce this?