Open borissim opened 7 years ago
Right. The comment above the failing line claims that "python's uniform is perfect since the upper limit is not inclusive". But rand() isn't from python, it's from C. And the C standard says rand() is inclusive, 0<=rand()<=RAND_MAX.
I think the question is whether the intent was to have (RAND_MAX+1) as the denominator instead of RAND_MAX. That comment makes me think python's random.random() used to be used here.
Secondary questions would be (a) why the C PRNG is being used instead of the python PRNG, since C rand() implementations are usually poor, and (b) why a binomial distribution is being used instead of uniform.
same error, any update?
I create a lot of IntervalNode objects and eventually this error pops up
The issue seems to be that at
self.priority = ceil(nlog * log(-1.0/(1.0 * rand()/RAND_MAX - 1)))
I assume rand() can produce 0 or RAND_MAX, at which point *(1.0 rand()/RAND_MAX - 1)** equals 0, hence ZeroDivisionError is thrown