> But you should look the code above again to see if you really understood what the probability is for all possible results. I think you will find that all results have a 1 / (RAND_MAX + 1) probability. Not just 10.
Code:
std::rand() * 9.0 / RAND_MAX + 1;
Is that the piece of code you were talking about?
There's a world of difference between
Code:
std::rand() * 9.0 / RAND_MAX + 1
and
Code:
std::rand() * 9.0 / (RAND_MAX + 1)
Only your second code snippet that involved a bucket_size works as expected.