Boost logo

Boost :

From: Dave Abrahams (abrahams_at_[hidden])
Date: 1999-11-09 20:13:07

Here's something that's been bugging me as the proposals go by: isn't it
very likely that if you use a system with a uniform PRNG and a bunch of
"redistributors", that some representable values which should be generated
will be missed altogether due to the thinness of the local distribution?

For example, take this redistributor which cuts the probability of numbers
from zero to ULONG_MAX*2/3 in half, and doubles the probablility of the

#include <limits>
// Can never return 1,3,5...
unsigned long redistribute( unsigned long x )
    if (x < std::numeric_limits<unsigned long>::max() / 3)
        return 2 * x;
        return x/2 + 2 * (std::numeric_limits<unsigned long>::max() / 3);

This seems like it could be a problem for some applications

I've only been listening with half an ear here, so please feel free to tell
me I don't know what I'm talking about without launching into a lengthy
explanation if I'm just way off base.


Boost list run by bdawes at, gregod at, cpdaniel at, john at